tool_streaming.yaml

  1---
  2version: 2
  3interactions:
  4- id: 0
  5  request:
  6    proto: HTTP/1.1
  7    proto_major: 1
  8    proto_minor: 1
  9    content_length: 507
 10    host: ""
 11    body: '{"messages":[{"content":"You are a helpful assistant","role":"system"},{"content":"What''s the weather in Florence,Italy?","role":"user"}],"model":"grok-4-fast","max_tokens":4000,"stream_options":{"include_usage":true},"tool_choice":"auto","tools":[{"function":{"name":"weather","strict":false,"description":"Get weather information for a location","parameters":{"properties":{"location":{"description":"the city","type":"string"}},"required":["location"],"type":"object"}},"type":"function"}],"stream":true}'
 12    headers:
 13      Accept:
 14      - application/json
 15      Content-Type:
 16      - application/json
 17      User-Agent:
 18      - Charm-Fantasy/0.12.2 (https://charm.land/fantasy)
 19    url: https://api.x.ai/v1/chat/completions
 20    method: POST
 21  response:
 22    proto: HTTP/2.0
 23    proto_major: 2
 24    proto_minor: 0
 25    content_length: -1
 26    body: |+
 27      data: {"id":"8f008308-984b-9603-8706-ebf37f518892","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"role":"assistant","tool_calls":[{"id":"call_51851897","function":{"name":"weather","arguments":"{\"location\":\"Florence, Italy\"}"},"index":0,"type":"function"}]}}],"system_fingerprint":"fp_3d7ed3b779"}
 28
 29      data: {"id":"8f008308-984b-9603-8706-ebf37f518892","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{},"finish_reason":"tool_calls"}],"system_fingerprint":"fp_3d7ed3b779"}
 30
 31      data: {"id":"8f008308-984b-9603-8706-ebf37f518892","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[],"usage":{"prompt_tokens":361,"completion_tokens":26,"total_tokens":622,"prompt_tokens_details":{"text_tokens":361,"audio_tokens":0,"image_tokens":0,"cached_tokens":360},"completion_tokens_details":{"reasoning_tokens":235,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0},"num_sources_used":0,"cost_in_usd_ticks":1487000},"system_fingerprint":"fp_3d7ed3b779"}
 32
 33      data: [DONE]
 34
 35    headers:
 36      Content-Type:
 37      - text/event-stream
 38    status: 200 OK
 39    code: 200
 40    duration: 667.752292ms
 41- id: 1
 42  request:
 43    proto: HTTP/1.1
 44    proto_major: 1
 45    proto_minor: 1
 46    content_length: 727
 47    host: ""
 48    body: '{"messages":[{"content":"You are a helpful assistant","role":"system"},{"content":"What''s the weather in Florence,Italy?","role":"user"},{"tool_calls":[{"id":"call_51851897","function":{"arguments":"{\"location\":\"Florence, Italy\"}","name":"weather"},"type":"function"}],"role":"assistant"},{"content":"40 C","tool_call_id":"call_51851897","role":"tool"}],"model":"grok-4-fast","max_tokens":4000,"stream_options":{"include_usage":true},"tool_choice":"auto","tools":[{"function":{"name":"weather","strict":false,"description":"Get weather information for a location","parameters":{"properties":{"location":{"description":"the city","type":"string"}},"required":["location"],"type":"object"}},"type":"function"}],"stream":true}'
 49    headers:
 50      Accept:
 51      - application/json
 52      Content-Type:
 53      - application/json
 54      User-Agent:
 55      - Charm-Fantasy/0.12.2 (https://charm.land/fantasy)
 56    url: https://api.x.ai/v1/chat/completions
 57    method: POST
 58  response:
 59    proto: HTTP/2.0
 60    proto_major: 2
 61    proto_minor: 0
 62    content_length: -1
 63    body: |+
 64      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":"The","role":"assistant"}}],"system_fingerprint":"fp_3d7ed3b779"}
 65
 66      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" current"}}],"system_fingerprint":"fp_3d7ed3b779"}
 67
 68      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" weather"}}],"system_fingerprint":"fp_3d7ed3b779"}
 69
 70      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" in"}}],"system_fingerprint":"fp_3d7ed3b779"}
 71
 72      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" Florence"}}],"system_fingerprint":"fp_3d7ed3b779"}
 73
 74      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":","}}],"system_fingerprint":"fp_3d7ed3b779"}
 75
 76      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" Italy"}}],"system_fingerprint":"fp_3d7ed3b779"}
 77
 78      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":","}}],"system_fingerprint":"fp_3d7ed3b779"}
 79
 80      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" is"}}],"system_fingerprint":"fp_3d7ed3b779"}
 81
 82      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" "}}],"system_fingerprint":"fp_3d7ed3b779"}
 83
 84      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":"40"}}],"system_fingerprint":"fp_3d7ed3b779"}
 85
 86      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":"°C"}}],"system_fingerprint":"fp_3d7ed3b779"}
 87
 88      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" ("}}],"system_fingerprint":"fp_3d7ed3b779"}
 89
 90      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345555,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":"104"}}],"system_fingerprint":"fp_3d7ed3b779"}
 91
 92      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":"°F"}}],"system_fingerprint":"fp_3d7ed3b779"}
 93
 94      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":")."}}],"system_fingerprint":"fp_3d7ed3b779"}
 95
 96      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" It"}}],"system_fingerprint":"fp_3d7ed3b779"}
 97
 98      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" feels"}}],"system_fingerprint":"fp_3d7ed3b779"}
 99
100      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" quite"}}],"system_fingerprint":"fp_3d7ed3b779"}
101
102      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" hot"}}],"system_fingerprint":"fp_3d7ed3b779"}
103
104      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":"—"}}],"system_fingerprint":"fp_3d7ed3b779"}
105
106      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":"stay"}}],"system_fingerprint":"fp_3d7ed3b779"}
107
108      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" hydrated"}}],"system_fingerprint":"fp_3d7ed3b779"}
109
110      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" if"}}],"system_fingerprint":"fp_3d7ed3b779"}
111
112      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" you're"}}],"system_fingerprint":"fp_3d7ed3b779"}
113
114      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" out"}}],"system_fingerprint":"fp_3d7ed3b779"}
115
116      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" and"}}],"system_fingerprint":"fp_3d7ed3b779"}
117
118      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" about"}}],"system_fingerprint":"fp_3d7ed3b779"}
119
120      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":"!"}}],"system_fingerprint":"fp_3d7ed3b779"}
121
122      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" If"}}],"system_fingerprint":"fp_3d7ed3b779"}
123
124      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" you"}}],"system_fingerprint":"fp_3d7ed3b779"}
125
126      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" need"}}],"system_fingerprint":"fp_3d7ed3b779"}
127
128      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" a"}}],"system_fingerprint":"fp_3d7ed3b779"}
129
130      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" forecast"}}],"system_fingerprint":"fp_3d7ed3b779"}
131
132      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" or"}}],"system_fingerprint":"fp_3d7ed3b779"}
133
134      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" more"}}],"system_fingerprint":"fp_3d7ed3b779"}
135
136      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" details"}}],"system_fingerprint":"fp_3d7ed3b779"}
137
138      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":","}}],"system_fingerprint":"fp_3d7ed3b779"}
139
140      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" let"}}],"system_fingerprint":"fp_3d7ed3b779"}
141
142      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" me"}}],"system_fingerprint":"fp_3d7ed3b779"}
143
144      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":" know"}}],"system_fingerprint":"fp_3d7ed3b779"}
145
146      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"content":"."}}],"system_fingerprint":"fp_3d7ed3b779"}
147
148      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"system_fingerprint":"fp_3d7ed3b779"}
149
150      data: {"id":"ed3edf28-66f2-3e19-5699-c301241be2b3","object":"chat.completion.chunk","created":1773345556,"model":"grok-4-fast-reasoning","choices":[],"usage":{"prompt_tokens":635,"completion_tokens":42,"total_tokens":720,"prompt_tokens_details":{"text_tokens":635,"audio_tokens":0,"image_tokens":0,"cached_tokens":623},"completion_tokens_details":{"reasoning_tokens":43,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0},"num_sources_used":0,"cost_in_usd_ticks":760500},"system_fingerprint":"fp_3d7ed3b779"}
151
152      data: [DONE]
153
154    headers:
155      Content-Type:
156      - text/event-stream
157    status: 200 OK
158    code: 200
159    duration: 432.121666ms