Responses API

POST https://llmoxy.com/v1/responses nhận JSON. Header:

Authorization: Bearer <LLMOXY_API_KEY>
Content-Type: application/json

Cổng phân tích thân request theo một cấu trúc cố định. Request bị từ chối khi model rỗng, khi không có input, hoặc khi max_output_tokens lớn hơn 1.073.741.823. background không nằm trong cấu trúc này.

Khi không bật chuyển nguyên thân request, chỉ các trường trong bảng được giữ, và service_tier, safety_identifier cùng stream_options.include_obfuscation bị bỏ theo mặc định. store được giữ. Số có thể trống ghi 0 và stream ghi false vẫn được gửi. Giá trị boolean false trong stream_options bị bỏ khi dựng lại thân request. Trường ngoài bảng không được gửi.

Trường request

TrườngKiểuBắt buộcCách cổng xử lý
modelstringcóID mô hình không rỗng.
inputstring hoặc arraycóPhải có mặt. Chuỗi được tính là một đoạn văn bản đầu vào. Phần tử mảng có thể kèm role. content dạng chuỗi được tính là văn bản. content dạng mảng nhận input_text, input_image và input_file. image_url và file_url có thể là chuỗi hoặc object có url.
includeJSONkhôngGiữ nguyên.
conversationJSONkhôngGiữ nguyên.
context_managementJSONkhôngGiữ nguyên.
instructionsJSONkhôngGiữ nguyên. Dạng thường gặp là chuỗi.
max_output_tokensnumberkhôngCó thể trống. 0 tường minh được giữ.
top_logprobsnumberkhôngCó thể trống. 0 tường minh được giữ.
metadataJSONkhôngGiữ nguyên.
parallel_tool_callsJSONkhôngGiữ nguyên. false tường minh được giữ.
previous_response_idstringkhôngChuỗi rỗng bị bỏ.
reasoning.effortstringkhôngChuỗi rỗng bị bỏ. Cổng không kiểm tra giá trị.
reasoning.summarystringkhôngChuỗi rỗng bị bỏ. Cổng không kiểm tra giá trị.
service_tierstringkhôngMặc định bị bỏ.
storeJSONkhôngMặc định được giữ. false tường minh được giữ.
prompt_cache_keyJSONkhôngGiữ nguyên.
prompt_cache_retentionJSONkhôngGiữ nguyên.
safety_identifierJSONkhôngMặc định bị bỏ.
streambooleankhôngVắng mặt nghĩa là request không stream. false tường minh được giữ.
stream_options.include_usagebooleankhôngKhi dựng lại, false bị bỏ.
stream_options.include_obfuscationbooleankhôngMặc định bị bỏ. Khi dựng lại, false bị bỏ.
temperaturenumberkhôngCó thể trống. 0 tường minh được giữ.
textJSONkhôngGiữ nguyên.
tool_choiceJSONkhôngGiữ nguyên.
toolsJSONkhôngGiữ nguyên.
top_pnumberkhôngCó thể trống. 0 tường minh được giữ.
truncationJSONkhôngGiữ nguyên.
userJSONkhôngGiữ nguyên.
max_tool_callsnumberkhôngCó thể trống. 0 tường minh được giữ.
promptJSONkhôngGiữ nguyên.
enable_thinkingJSONkhôngGiữ nguyên.
presetJSONkhôngGiữ nguyên.

grok-4.6 và grok-4.7

Ngày 2026-10-03, lệnh gọi stream tới https://llmoxy.com/v1/responses cho grok-4.6 và grok-4.7 đều trả HTTP 200 và cùng một dãy sự kiện.

Mô hìnhHTTPmodel trong phản hồistatusVăn bảninput / output / total
grok-4.6200grok-4.6completedpong212 / 98 / 310
grok-4.7200grok-4.7completedpong1248 / 55 / 1303

Với grok-4.6, input_tokens_details.cached_tokens là 128 và output_tokens_details.reasoning_tokens là 97. Với grok-4.7, hai giá trị đó là 1152 và 54.

Văn bản nằm ở phần tử output có type là message, trong content có type là output_text, trường text. Cả hai mô hình đều phát trước một phần tử type là reasoning. Trong response.completed, status của phần tử reasoning đó vẫn là in_progress.

Request của hai mô hình này bật chuyển nguyên thân request, nên JSON tối thiểu ở mục sau được gửi đúng như client đã viết.

Request tối thiểu đã thành công

Với grok-4.6, dùng cùng thân request và đổi model thành grok-4.6.

curl https://llmoxy.com/v1/responses \
  -H "Authorization: Bearer <LLMOXY_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-4.7",
    "input": "Reply with exactly: pong",
    "max_output_tokens": 64,
    "stream": true
  }'
BASH

Content-Type của phản hồi là text/event-stream. Mỗi sự kiện gồm một dòng event: và một dòng data:. Cổng chuyển nguyên JSON của sự kiện đã phân tích được, và tên sự kiện lấy từ type. Stream kết thúc bằng response.completed cuối cùng.

Hai mô hình phát cùng tên sự kiện theo thứ tự này:

response.created, response.in_progress, response.output_item.added, response.reasoning_summary_part.added, response.reasoning_summary_text.delta, response.reasoning_summary_text.delta, response.reasoning_summary_text.done, response.reasoning_summary_part.done, response.output_item.done, response.output_item.added, response.content_part.added, response.output_text.delta, response.output_text.done, response.content_part.done, response.output_item.done, response.completed.

Đoạn dưới là phản hồi grok-4.7. ID phản hồi và ID phần tử đã được đổi thành chỗ giữ chỗ. Các trường còn lại khớp với lần gọi đó.

event: response.created
data: {"type":"response.created","sequence_number":0,"response":{"object":"response","id":"resp_example","created_at":1791015238,"model":"grok-4.7","output":[],"status":"in_progress"},"output_index":0}

event: response.in_progress
data: {"type":"response.in_progress","sequence_number":1,"response":{"object":"response","id":"resp_example","created_at":1791015238,"model":"grok-4.7","output":[],"status":"in_progress"},"output_index":0}

event: response.output_item.added
data: {"type":"response.output_item.added","sequence_number":2,"output_index":0,"item":{"id":"item_reasoning","type":"reasoning","status":"in_progress","summary":[]}}

event: response.reasoning_summary_part.added
data: {"type":"response.reasoning_summary_part.added","sequence_number":3,"output_index":0,"item_id":"item_reasoning","part":{"type":"summary_text","text":""},"summary_index":0}

event: response.reasoning_summary_text.delta
data: {"type":"response.reasoning_summary_text.delta","sequence_number":4,"output_index":0,"item_id":"item_reasoning","delta":"The user wants a reply","summary_index":0}

event: response.reasoning_summary_text.delta
data: {"type":"response.reasoning_summary_text.delta","sequence_number":5,"output_index":0,"item_id":"item_reasoning","delta":" of exactly \"pong\".","summary_index":0}

event: response.reasoning_summary_text.done
data: {"type":"response.reasoning_summary_text.done","sequence_number":6,"output_index":0,"item_id":"item_reasoning","text":"The user wants a reply of exactly \"pong\".","summary_index":0}

event: response.reasoning_summary_part.done
data: {"type":"response.reasoning_summary_part.done","sequence_number":7,"output_index":0,"item_id":"item_reasoning","part":{"type":"summary_text","text":"The user wants a reply of exactly \"pong\"."},"summary_index":0}

event: response.output_item.done
data: {"type":"response.output_item.done","sequence_number":8,"output_index":0,"item":{"id":"item_reasoning","type":"reasoning","summary":[{"text":"The user wants a reply of exactly \"pong\".","type":"summary_text"}]}}

event: response.output_item.added
data: {"type":"response.output_item.added","sequence_number":9,"output_index":1,"item":{"id":"item_message","type":"message","role":"assistant","content":[],"status":"in_progress"}}

event: response.content_part.added
data: {"type":"response.content_part.added","sequence_number":10,"output_index":1,"item_id":"item_message","content_index":0,"part":{"type":"output_text","text":"","annotations":[]}}

event: response.output_text.delta
data: {"type":"response.output_text.delta","sequence_number":11,"output_index":1,"item_id":"item_message","content_index":0,"delta":"pong"}

event: response.output_text.done
data: {"type":"response.output_text.done","sequence_number":12,"output_index":1,"item_id":"item_message","content_index":0,"text":"pong"}

event: response.content_part.done
data: {"type":"response.content_part.done","sequence_number":13,"output_index":1,"item_id":"item_message","content_index":0,"part":{"type":"output_text","text":"pong","annotations":[]}}

event: response.output_item.done
data: {"type":"response.output_item.done","sequence_number":14,"output_index":1,"item":{"id":"item_message","type":"message","role":"assistant","content":[{"type":"output_text","annotations":[],"text":"pong"}],"status":"completed"}}

event: response.completed
data: {"type":"response.completed","sequence_number":15,"response":{"object":"response","id":"resp_example","created_at":1791015238,"model":"grok-4.7","output":[{"id":"item_reasoning","type":"reasoning","status":"in_progress","summary":[{"text":"The user wants a reply of exactly \"pong\".","type":"summary_text"}]},{"id":"item_message","type":"message","role":"assistant","content":[{"type":"output_text","text":"pong"}],"status":"completed"}],"status":"completed","usage":{"input_tokens":1248,"input_tokens_details":{"cached_tokens":1152},"output_tokens":55,"output_tokens_details":{"reasoning_tokens":54},"total_tokens":1303}},"output_index":0}

Nén hội thoại

POST https://llmoxy.com/v1/responses/compact

Các trường là model (bắt buộc), input, instructions, previous_response_id. Lần đo grok ở trên không gọi route này.