API and SDKs
Chat Completions
Create a model response for a conversation, in OpenAI's Chat Completions format.
https://api.impact-relay.com/ v1/ chat/ completions- Format
- OpenAI format
- Auth header
- Authorization: Bearer
- SDK base URL
- https://api.impact-relay.com/v1
Works with the OpenAI SDKs and any OpenAI-compatible client, for every language model on Models. The same models answer in OpenAI's Responses format at Responses, in the Anthropic format at Messages and in the Gemini format at generateContent; to set up a client, see SDKs.
Request
Headers
2
Bearerand your API key. The key is read fromx-api-keyas well.- Content-Encodingstring
Set it when the JSON body is compressed. A body may be up to 32 MiB, compressed and expanded alike.
Valuesgzipzstdbrdeflate
Body
application/jsonA language model ID from Models, such as
claude-sonnet-5-5, orautoorpreset/<slug>for smart routing. An image, video or embedding model's ID is refused with a400that names its endpoint.The conversation so far, oldest first. It can't be empty.
Show item propertiesHide item properties
Who wrote the message.
systemanddevelopermessages are the model's instructions.Valuessystemdeveloperuserassistanttool- messages[].contentstring | object[]
The message's text, or a list of parts: text and images.
Show item propertiesHide item properties
The kind of part. A
fileorinput_audiopart is refused with a400.typetext The text of a
textpart.
typeimage_url An image as an
https:or base64data:URL: the URL itself, or an object withurlanddetail.
- messages[].tool_callsobject[]
In an
assistantmessage: the function calls the model made, each with itsid,function.nameandfunction.arguments. - messages[].tool_call_idstring
In a
toolmessage: theidof the call it answers. Required there. In an
assistantmessage: the reasoning that came with the answer, sent back as it arrived.
- max_completion_tokensinteger
The most tokens the answer may take, up to the model's maximum output. Left out, the model's maximum applies.
- max_tokensinteger
The older name of
max_completion_tokens: read only when that field isn't sent. - reasoning_effortstring
How hard the model reasons. The nearest level the model has is used, and a model that doesn't reason ignores it.
reasoning.effortis read the same way.Valuesnoneminimallowmediumhighxhighmaxultra - toolsobject[]
The tools the model may call: functions, and
web_search, which turns on web search.Show item propertiesHide item properties
functionfor a function of yours;web_searchorweb_search_previewfor web search. Any other type is refused with a400.Valuesfunctionweb_searchweb_search_preview- tools[].functionobject
The function, for a tool of type
function.Show propertiesHide properties
The function's name.
What the function does: the model reads it to decide when to call.
The function's arguments as a JSON Schema object. Left out, the function takes none.
- tools[].function.strictboolean
Whether the model must follow the schema exactly, on models that can.
- tool_choicestring | object
auto,noneorrequired; or an object withfunction.nameto force that function. - response_formatobject
The shape of the answer: plain text, any JSON object, or JSON that follows your schema.
Show propertiesHide properties
The kind of answer. Any other type is refused with a
400.Valuestextjson_objectjson_schemaFor
json_schema: theschemaitself, with an optionalname,descriptionandstrict.
- streamboolean
trueanswers with server-sent events instead of one JSON body. See Streaming.Defaultfalse - temperaturenumber
Sampling temperature, passed on where the model takes it. Left out, the model's own default applies.
More parameters8
- parallel_tool_callsboolean
falsekeeps the model to one function call a turn. - stream_optionsobject
Options of a streamed answer.
Show propertiesHide properties
- stream_options.include_usageboolean
trueadds a last chunk withusage: token counts andusage.cost.Defaultfalse
- top_pnumber
Nucleus sampling, passed on where the model takes it.
- stopstring | string[]
One sequence or a list of them: the answer ends before the first one the model writes.
- web_search_optionsobject
Any value turns on web search, as a
web_searchtool does. - prompt_cache_keystring
A stable ID for the conversation. Requests that share one hit the prompt cache more often.
- userstring
An ID of your own end user. Providers never get it as sent, only an anonymous digest of it.
- ninteger
Only
1is served: a larger number is refused with a400.
Other fields
Any other field of OpenAI's API is accepted and ignored, among them
seed,logprobs,presence_penalty,frequency_penalty,logit_bias,metadata,storeandservice_tier. OpenAI's reference says what they do there.
Response
200application/json
Response body
- idstring
The request's ID,
gen_…, the same as thex-request-idheader. Look it up in Logs. - modelstring
The ID of the model that answered, as on Models. A request for
autoor a preset gets back the ID it asked for. - choicesobject[]
One choice: the answer.
Show item propertiesHide item properties
- choices[].indexinteger
Always
0. - choices[].messageobject
The model's message.
Show propertiesHide properties
- choices[].message.rolestring
Always
assistant. - choices[].message.contentstring | null
The answer's text;
nullwhen the turn is only function calls. The model's reasoning, when the provider returns it.
- choices[].message.tool_callsobject[]
The function calls the model made, each with an
id,type(function),function.nameandfunction.arguments, a JSON string.
- choices[].finish_reasonstring
Why the answer ended.
lengthis the token limit;content_filtermeans the model declined to answer.Valuesstoplengthtool_callscontent_filter
- usageobject
What the request used.
Show propertiesHide properties
- usage.prompt_tokensinteger
Input tokens, cached ones included.
cached_tokens: input read from the prompt cache.cache_write_tokens, when above zero: input written to it.- usage.completion_tokensinteger
Output tokens, reasoning included.
reasoning_tokens: the part of the output spent on reasoning.- usage.total_tokensinteger
Input and output together.
- usage.costnumber
What the request took from your plan credits or balance, in dollars.
Response headers
3
- x-request-idstring
The request's ID, on every response and every error;
request-idcarries it too. It finds a request that reached a model in Logs; quote it to support. - x-impact-routed-modelstring
On a request for
autoor a preset: the model smart routing chose. - x-impact-routing-reasonstring
On a request for
autoor a preset: why that model was chosen, such asupgraded,kept,pinned,subagentorfallback.
Streaming
With stream: true the answer arrives as server-sent events: chat.completion.chunk objects in the order below, each on a data: line. While the model is quiet, : keep-alive comments hold the connection open, and the SDKs skip them. Time limits and failures midway are the same in every format: Streaming.
- delta.role
The first chunk opens the message:
delta.roleisassistant. - delta.content
Text as it is written, a piece per chunk.
delta.reasoning_contentcarries reasoning the same way. - delta.tool_calls
A function call: its
idand name first, then its arguments in pieces. - finish_reason
The answer's last chunk has an empty
deltaand thefinish_reason. - usage
With
stream_options.include_usage: one more chunk with emptychoices, holdingusageand itscost. - [DONE]
data: [DONE]ends the stream. A failure midway arrives as a chunk holdingerrorinstead.
Errors
Errors come in the OpenAI format, an error object with code, message, type and request_id.
- 400invalid_request
A malformed body, a field of the wrong type or out of range, or something this endpoint refuses:
nabove 1, audio or file input, an unknown tool type.
The same on every endpoint11
- 400unsupported_client
The client is unsupported or too old for this model. Follow the error's message: update Codex to the latest version, or use the official Claude Code client.
- 401invalid_api_key
The key is missing, mistyped or revoked. Check it in API keys.
- 402insufficient_credits
Plan credits, the available balance or the key's monthly limit can't cover the request's estimated cost. Top up on Billing.
- 404model_not_found
No model has this ID, or the model isn't available right now. See Models.
- 413context_length_exceeded
The input is longer than the model's context window.
- 429rate_limit_exceeded
The provider is rate-limiting the model, or the model is busy for more than 5 minutes. Retry after
Retry-After. - 500internal_error
Impact itself failed. Retry.
- 502upstream_error
The provider returned an error. Retry.
- 503server_is_overloaded
Every source of the model is busy for now. Retry after
Retry-After, with backoff. - 504upstream_timeout
The provider didn't answer in time, or the request passed the 30-minute limit. Retry.
Every error in every format, and when to retry: Errors.
A model that declines to answer is usually not an error: the response succeeds with finish_reason set to content_filter. A prompt that a provider refuses outright is a 400 invalid_request.
Differences from OpenAI's API
Not supported
nabove 1: one answer per request.- Audio input and
fileparts. Send a file's contents as text. - Tools other than functions and web search.
Ignored · Works differently · Added by Impact8
Ignored
- Fields this page doesn't list, such as
seed,logprobs,presence_penalty,frequency_penalty,logit_bias,metadata,storeandservice_tier. temperatureandtop_pon models that don't take them.
Works differently
reasoning_efforttakes more levels than OpenAI's, fromnonetoultra, and is mapped to the nearest one the model has.
Added by Impact
usage.cost: what the request cost, in dollars.idis the request's ID in Logs, and thex-request-idheader.autoandpreset/<slug>as the model: smart routing picks the model and names it inx-impact-routed-model.reasoning_contenton the answer's message and in stream deltas, when the provider returns reasoning.- A
web_searchtool orweb_search_optionsruns Impact's web search with any model.
Models
model takes any language model ID from Models, the catalog with context windows and prices. A model keeps its ID. GET /v1/models with the same key lists them with their context windows, reasoning levels and prices: List models.
Other endpoints
- Responses —
POST /v1/responses, the OpenAI Responses endpoint for Codex andresponses.create, with every language model. - Messages and generateContent — free token counting in the Anthropic and Gemini formats.
- Images —
POST /v1/images/generationsand/v1/images/editsfor image models. - Videos —
POST /v1/videos/generations,/v1/videos/editsand/v1/videos/extensionsfor asynchronous MP4 jobs. - Embeddings —
POST /v1/embeddingsfor free text embeddings.