POST /v1/responses endpoint. Code written for client.responses.create(...) in the OpenAI SDK works after changing the base_url and api_key.
The endpoint is non-streaming and text-only. It runs through the same path as /v1/chat/completions, so model routing, billing, rate limits and logging are the same.
Endpoint Information
- URL:
/v1/responses - Method:
POST - Authentication: Required (
x-api-keyheader orAuthorization: Bearer <key>) - Rate Limiting: Subject to tier-based rate limits
- API reference: Create a response (OpenAI-compatible, non-streaming)
Quick Start
- Python
- cURL
Request Fields
Message Items
Wheninput is a list, each item is a message:
roleisuser,assistant,systemordeveloper.systemanddevelopermessages become part of the system prompt.contentis a string, or a list ofinput_text/output_textparts, e.g.[{"type": "input_text", "text": "..."}]. The parts’ text is joined with spaces.- An item’s
type, if set, must bemessage.
Not Supported Yet
These return 400 with"Not supported yet: <field>" or a message naming the problem:
stream: truetoolsprevious_response_id- Any other field not listed above, when set to a non-empty value
- Image or file content parts, and item types other than
message(e.g. function call items) inputwith nousermessage
Response Fields
Errors
Errors use the OpenAI error shape, so the OpenAI SDK’s exception classes work:
As on
/v1/chat/completions, 401 and 402 come from the authentication layer in the Swarms shape (error.type, error.message, error.detail, error.status_code). See Error Response Schema.
Billing
Billing, rate limits and the minimum balance are the same as/v1/chat/completions: the provider-reported input and output tokens at the model’s price plus a 15% service fee, deducted after the run. The endpoint is billable, so it needs a purchased credit balance above $1.00. See Pricing.
Related
- OpenAI-Compatible Endpoint —
POST /v1/chat/completions, with streaming and tool calling - Anthropic-Compatible Messages API —
POST /v1/messagesfor the Anthropic SDK - OpenAI-Compatible Examples