Skip to content
Sign in

API and SDKs

Chat Completions

Create a model response for a conversation, in OpenAI's Chat Completions format.

POSThttps://api.impact-relay.com/v1/chat/completions
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
  • Authorizationstringrequired

    Bearer and your API key. The key is read from x-api-key as well.

  • Set it when the JSON body is compressed. A body may be up to 32 MiB, compressed and expanded alike.

    Valuesgzipzstdbrdeflate

Body

application/json
  • modelstringrequired

    A language model ID from Models, such as claude-sonnet-5-5, or auto or preset/<slug> for smart routing. An image, video or embedding model's ID is refused with a 400 that names its endpoint.

  • messagesobject[]required

    The conversation so far, oldest first. It can't be empty.

    Show item properties
    • messages[].rolestringrequired

      Who wrote the message. system and developer messages are the model's instructions.

      Valuessystemdeveloperuserassistanttool
    • messages[].contentstring | object[]

      The message's text, or a list of parts: text and images.

      Show item properties

      The kind of part. A file or input_audio part is refused with a 400.

      typetext
      typeimage_url
    • In an assistant message: the function calls the model made, each with its id, function.name and function.arguments.

    • In a tool message: the id of the call it answers. Required there.

    • In an assistant message: the reasoning that came with the answer, sent back as it arrived.

  • 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.

  • How hard the model reasons. The nearest level the model has is used, and a model that doesn't reason ignores it. reasoning.effort is read the same way.

    Valuesnoneminimallowmediumhighxhighmaxultra
  • toolsobject[]

    The tools the model may call: functions, and web_search, which turns on web search.

    Show item properties
    • tools[].typestringrequired

      function for a function of yours; web_search or web_search_preview for web search. Any other type is refused with a 400.

      Valuesfunctionweb_searchweb_search_preview
    • The function, for a tool of type function.

      Show properties
  • tool_choicestring | object

    auto, none or required; or an object with function.name to force that function.

  • The shape of the answer: plain text, any JSON object, or JSON that follows your schema.

    Show properties
    • response_format.typestringrequired

      The kind of answer. Any other type is refused with a 400.

      Valuestextjson_objectjson_schema
    • For json_schema: the schema itself, with an optional name, description and strict.

  • streamboolean

    true answers with server-sent events instead of one JSON body. See Streaming.

    Defaultfalse
  • Sampling temperature, passed on where the model takes it. Left out, the model's own default applies.

  • More parameters8
    • false keeps the model to one function call a turn.

    • Options of a streamed answer.

      Show properties
    • 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.

    • Any value turns on web search, as a web_search tool does.

    • 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 1 is served: a larger number is refused with a 400.

  • Other fields

    Any other field of OpenAI's API is accepted and ignored, among them seed, logprobs, presence_penalty, frequency_penalty, logit_bias, metadata, store and service_tier. OpenAI's reference says what they do there.

Response

200application/json

Response body

Response headers

3
  • The request's ID, on every response and every error; request-id carries it too. It finds a request that reached a model in Logs; quote it to support.

  • On a request for auto or a preset: the model smart routing chose.

  • On a request for auto or a preset: why that model was chosen, such as upgraded, kept, pinned, subagent or fallback.

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.

  1. delta.role

    The first chunk opens the message: delta.role is assistant.

  2. delta.content

    Text as it is written, a piece per chunk. delta.reasoning_content carries reasoning the same way.

  3. delta.tool_calls

    A function call: its id and name first, then its arguments in pieces.

  4. finish_reason

    The answer's last chunk has an empty delta and the finish_reason.

  5. usage

    With stream_options.include_usage: one more chunk with empty choices, holding usage and its cost.

  6. [DONE]

    data: [DONE] ends the stream. A failure midway arrives as a chunk holding error instead.

Errors

Errors come in the OpenAI format, an error object with code, message, type and request_id.

  • 400
    invalid_request

    A malformed body, a field of the wrong type or out of range, or something this endpoint refuses: n above 1, audio or file input, an unknown tool type.

The same on every endpoint11

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

  • n above 1: one answer per request.
  • Audio input and file parts. 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, store and service_tier.
  • temperature and top_p on models that don't take them.

Works differently

  • reasoning_effort takes more levels than OpenAI's, from none to ultra, and is mapped to the nearest one the model has.

Added by Impact

  • usage.cost: what the request cost, in dollars.
  • id is the request's ID in Logs, and the x-request-id header.
  • auto and preset/<slug> as the model: smart routing picks the model and names it in x-impact-routed-model.
  • reasoning_content on the answer's message and in stream deltas, when the provider returns reasoning.
  • A web_search tool or web_search_options runs 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 and responses.create, with every language model.
  • Messages and generateContent — free token counting in the Anthropic and Gemini formats.
  • Images — POST /v1/images/generations and /v1/images/edits for image models.
  • Videos — POST /v1/videos/generations, /v1/videos/edits and /v1/videos/extensions for asynchronous MP4 jobs.
  • Embeddings — POST /v1/embeddings for free text embeddings.