Skip to main content
DeepInfra serves the OpenAI Responses API for every chat model in our catalog. It runs on the same models, pricing and rate limits as Chat Completions, so pick the API your client speaks. The OpenAI Agents SDK and Codex CLI speak Responses. The endpoint is:
The same route answers at https://api.deepinfra.com/v1/openai/responses, so an OpenAI client whose base_url is https://api.deepinfra.com/v1/openai needs no other change.
The API is stateless: DeepInfra does not store responses. Send the conversation so far with every request, as shown in Conversations. previous_response_id, conversation and background are not supported.

Example

The reply is a response object. output is a list of typed items: message, function_call and reasoning.

Conversations

To continue a conversation, send the earlier turns again. Append the output items of the previous response to your input, then add the new message:
store is accepted, and every response reports store: false. GET and DELETE /v1/responses/{id} return 404.

Function calling

Tools use the Responses shape: name, description and parameters sit at the top level of the tool, not under a function key as in Chat Completions.
function_call_output.output is a string, or an array of input_text and input_image parts. An image part needs a vision model. Only function tools are supported. See Tool Calling for more on tools.

Structured outputs

Set text.format to json_object, or to json_schema with a schema to enforce:
See Structured Outputs for the two modes and model support.

Reasoning

reasoning.effort takes the same values as reasoning_effort on Chat Completions; see Reasoning Models. The reasoning comes back as a reasoning item ahead of the message, with the text in content:
Open models reason in plain text, so summary is empty and no encrypted_content is returned. reasoning.summary and include: ["reasoning.encrypted_content"] are accepted and ignored. Keep reasoning items in the output you replay on the next turn: they are accepted as input.

Images

On a vision model, add input_image parts to a user message. image_url is an HTTPS URL or a data: URL; file_id is not supported.

Streaming

Set stream to true to receive typed server-sent events:
A response that stops at max_output_tokens ends with response.incomplete and incomplete_details.reason.

Supported parameters

These fields are rejected with a 400, so a request never runs with part of it silently dropped:
  • previous_response_id, conversation, background
  • max_tool_calls, truncation: "auto", prompt, text.verbosity
  • top_logprobs and include: ["message.output_text.logprobs"]
  • input_file parts, and input_image with a file_id
  • Hosted tools: file_search, code_interpreter, mcp, computer_use
A web_search tool is ignored when the model can’t serve it, because Codex attaches one to every request. For the full request and response schema, see the API reference.

Errors

Errors use the OpenAI error object. A prompt that does not fit the model’s context window fails with the code context_length_exceeded: as an HTTP 400 on a non-streaming request, and as a response.failed event on a streaming one.

OpenAI Agents SDK

The OpenAI Agents SDK uses the Responses API by default. Give it a client that points at DeepInfra:
Function tools, streaming with Runner.run_streamed and client-side sessions such as SQLiteSession work. The SDK’s hosted tools (FileSearchTool, CodeInterpreterTool, HostedMCPTool) run on OpenAI’s servers, and previous_response_id and conversation_id need stored responses, so those return a 400.

Codex CLI

Codex CLI talks to any Responses endpoint. Add DeepInfra as a model provider in ~/.codex/config.toml:
Then export your key and start Codex:
Codex has no built-in metadata for DeepInfra models and assumes a 272K-token context window. For a model with a smaller window, add model_context_window with its context size in tokens, listed on each model page, so Codex compacts the conversation in time. Codex caps this setting at 272K for models it does not know, so leave it out for a 1M model. If a request still does not fit, Codex stops the turn and reports that the context window is full. Run /compact to summarize the conversation, then continue.

Microsoft Agent Framework

See the Microsoft Agent Framework guide. Its Responses client keeps state on the server by default, so the guide uses the Chat Completions client.