complex_object_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: 1016
10    host: ""
11    body: '{"messages":[{"content":"Generate information about ''The Lord of the Rings'' book by J.R.R. Tolkien, including genres like fantasy and adventure, and its publication year (1954).","role":"user"}],"model":"grok-4-fast","max_tokens":4000,"stream_options":{"include_usage":true},"tool_choice":{"function":{"name":"Book"},"type":"function"},"tools":[{"function":{"name":"Book","strict":false,"description":"A book with title, author, genres, and publication year","parameters":{"properties":{"author":{"properties":{"name":{"description":"Author''s name","type":"string"},"nationality":{"description":"Author''s nationality","type":"string"}},"required":["name","nationality"],"type":"object"},"genres":{"description":"List of genres","items":{"type":"string"},"type":"array"},"published_year":{"description":"Year the book was published","type":"integer"},"title":{"description":"The book title","type":"string"}},"required":["title","author","genres","published_year"],"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":"3ad22016-09c0-a473-e780-916350777cc5","object":"chat.completion.chunk","created":1773345656,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{"role":"assistant","tool_calls":[{"id":"call_88118924","function":{"name":"Book","arguments":"{\"author\":{\"name\":\"J.R.R. Tolkien\",\"nationality\":\"British\"},\"genres\":[\"fantasy\",\"adventure\"],\"published_year\":1954,\"title\":\"The Lord of the Rings\"}"},"index":0,"type":"function"}]}}],"system_fingerprint":"fp_3d7ed3b779"}
28
29      data: {"id":"3ad22016-09c0-a473-e780-916350777cc5","object":"chat.completion.chunk","created":1773345656,"model":"grok-4-fast-reasoning","choices":[{"index":0,"delta":{},"finish_reason":"tool_calls"}],"system_fingerprint":"fp_3d7ed3b779"}
30
31      data: {"id":"3ad22016-09c0-a473-e780-916350777cc5","object":"chat.completion.chunk","created":1773345656,"model":"grok-4-fast-reasoning","choices":[],"usage":{"prompt_tokens":468,"completion_tokens":77,"total_tokens":1127,"prompt_tokens_details":{"text_tokens":468,"audio_tokens":0,"image_tokens":0,"cached_tokens":467},"completion_tokens_details":{"reasoning_tokens":582,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0},"num_sources_used":0,"cost_in_usd_ticks":3530500},"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: 756.12025ms