> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.mixlayer.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mixlayer.com/_mcp/server.

# Create a response

POST https://mixlayer.ai/v1/responses
Content-Type: application/json

Create a model response using the OpenAI Responses API shape. Use this endpoint when you want input items, function-call output items, [server-side tools](/server-side-tools), structured text output, response storage, or Responses-style streaming events.

Set `reasoning.effort` to `default`, `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max`, or omit it for the model default. Some models also support numeric reasoning effort. Check the model's [Mixlayer documentation page](/models) for supported values and ranges. Models reject unsupported efforts; see [Reasoning](/reasoning#model-mappings) for model-specific mappings.

Set `stream` to true to receive typed server-sent events; the stream ends with `data: [DONE]`.

Reference: https://docs.mixlayer.com/api-reference/inference-ap-is/responses/responses

## Authentication

- `Authorization` header (bearer token, required) — Mixlayer API key or console user session supplied as a Bearer token.

## Request

### Body (application/json)

This endpoint expects a CreateResponseRequest.

- `input` (ResponseInput, required) — Text prompt or Responses input items.
- `model` (string, required) — Model identifier.
- `frequency_penalty` (float, optional, nullable) — Penalizes tokens based on their frequency in the generated text.
- `include` (list of enum, optional, nullable) — Additional response fields to include.
  - Allowed values: `reasoning.encrypted_content`, `web_search_call.action.sources`
- `instructions` (string, optional, nullable) — System or developer instructions prepended to the request.
- `max_output_tokens` (integer, optional, nullable) — Maximum generated output tokens.
- `max_tool_calls` (integer, optional, nullable) — Maximum tool calls is not currently supported.
- `metadata` (any, optional) — Metadata stored with the response when `store` is `true`.
- `parallel_tool_calls` (boolean, optional, nullable, default: true) — Whether the model may emit multiple tool calls in one generation leg.
- `presence_penalty` (float, optional, nullable) — Penalizes tokens that have already appeared in the generated text.
- `previous_response_id` (string, optional, nullable) — Stored response to continue from.
- `prompt_cache_key` (string, optional, nullable) — Prompt-cache key echoed on the response object.
- `reasoning` (ResponseReasoningParam, optional, nullable)
- `repetition_penalty` (float, optional, nullable) — Multiplicative repetition penalty.
- `safety_identifier` (string, optional, nullable) — End-user or session identifier echoed on the response object.
- `service_tier` (enum, optional, nullable, default: default) — Service tier returned by the Responses API.
  - Allowed values: `default`
- `store` (boolean, optional, nullable, default: false) — Store the response for later use with `previous_response_id`.
- `stream` (boolean, optional, default: false) — If `true`, return Responses Server-Sent Events. Defaults to `false`.
- `stream_options` (ResponseStreamOptions, optional, nullable)
- `temperature` (float, optional, nullable) — Sampling temperature. Higher values make output more random.
- `text` (ResponseTextParam, optional, nullable)
- `tool_choice` (ResponsesToolChoice, optional, nullable)
- `tools` (list of ResponseToolParam, optional, nullable) — Function and hosted web-search tools available to the model.
- `top_k` (integer, optional, nullable) — Restricts sampling to the highest-probability tokens.
- `top_logprobs` (integer, optional, nullable, default: 0) — Log probabilities are not supported and must be zero.
- `top_p` (float, optional, nullable) — Nucleus sampling probability mass.
- `truncation` (enum, optional, nullable, default: disabled) — Truncation policy returned by the Responses API.
  - Allowed values: `disabled`
- `background` (boolean, optional, nullable, default: false) — Background processing is not supported and must be false.

## Response

### 200

A complete response or a stream of typed response events, selected by the request's `stream` field

- `background` (boolean, required) — Whether background processing was requested, always `false`.
- `created_at` (long, required) — Unix timestamp when the response was created.
- `frequency_penalty` (float, required) — Frequency penalty used for generation.
- `id` (string, required) — Unique response identifier.
- `metadata` (any, required) — Metadata stored with the response.
- `model` (string, required) — Model used to generate the response.
- `object` (enum, required) — Object type, always `response`.
  - Allowed values: `response`
- `output` (list of ResponseOutputItem, required) — Generated message, reasoning, and function-call items.
- `output_text` (string, required) — Concatenated text from output message content.
- `parallel_tool_calls` (boolean, required) — Whether tool calls may run in parallel.
- `presence_penalty` (float, required) — Presence penalty used for generation.
- `reasoning` (ResponseReasoningField, required) — Reasoning configuration used for generation.
- `service_tier` (enum, required) — Processing tier, always `default`.
  - Allowed values: `default`
- `status` (enum, required) — Response status: `in_progress`, `completed`, or `incomplete`.
  - Allowed values: `in_progress`, `completed`, `incomplete`
- `store` (boolean, required) — Whether the response was stored for later continuation.
- `text` (ResponseTextField, required) — Text output configuration.
- `tool_choice` (any, required) — Tool selection policy used for the response.
- `tools` (list of ResponseTool, required) — Function tools available to the model.
- `top_logprobs` (integer, required) — Number of top log probabilities requested, always zero.
- `top_p` (float, required) — Nucleus sampling value.
- `truncation` (enum, required) — Input truncation policy, always `disabled`.
  - Allowed values: `disabled`
- `completed_at` (long, optional, nullable) — Unix timestamp when the response completed.
- `error` (any, optional) — Response-level error details, when generation fails.
- `incomplete_details` (any, optional) — Details explaining why a response is incomplete, when applicable.
- `instructions` (string, optional, nullable) — System or developer instructions prepended to the request.
- `max_output_tokens` (integer, optional, nullable) — Maximum generated output tokens.
- `max_tool_calls` (integer, optional, nullable) — Maximum tool calls, when configured.
- `previous_response_id` (string, optional, nullable) — Stored response this response continues from.
- `prompt_cache_key` (string, optional, nullable) — Prompt-cache key supplied with the request.
- `safety_identifier` (string, optional, nullable) — End-user or session identifier supplied with the request.
- `temperature` (float, optional, nullable) — Sampling temperature used for generation.
- `usage` (ResponseUsage, optional, nullable)

## Errors

### 400 Bad Request Error

Invalid or unsupported request

- `error` (OpenAIErrorDetails, required)

### 401 Unauthorized Error

Missing or invalid API key

- `error` (OpenAIErrorDetails, required)

### 402 Payment Required Error

Billing is required

- `error` (OpenAIErrorDetails, required)

### 403 Forbidden Error

The API key lacks inference permission

- `error` (OpenAIErrorDetails, required)

### 429 Too Many Requests Error

Rate limit exceeded

- `error` (OpenAIErrorDetails, required)

### 500 Internal Server Error

Generation or response persistence failed

- `error` (OpenAIErrorDetails, required)

## Types

### ResponseInput

### ResponseReasoningParam

- `effort` (ResponseReasoningParamEffort, optional, nullable) — Reasoning effort: `default`, `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max`. Some models also support numeric reasoning effort. Check the model's [Mixlayer documentation page](/models) for supported values and ranges. Omit for the model default. See [Reasoning](/reasoning#model-mappings) for model-specific mappings and unsupported values.
- `generate_summary` (any, optional) — Deprecated reasoning summary field; non-null values are not supported.
- `summary` (any, optional) — Reasoning summaries are not currently supported.

### ResponseStreamOptions

- `include_obfuscation` (boolean, optional, nullable) — Accepted for OpenAI compatibility; obfuscation is not added by the gateway.

### ResponseTextParam

- `format` (ResponseTextFormatParam, optional, nullable)
- `verbosity` (any, optional) — Output verbosity is not currently supported.

### ResponsesToolChoice

### ResponseToolParam

### ResponseOutputItem

### ResponseReasoningField

- `effort` (string, optional, nullable) — Reasoning effort used for generation.
- `summary` (any, optional) — Reasoning summary configuration.

### ResponseTextField

- `format` (ResponseTextFormatField, required) — Output format configuration.

### ResponseTool

### ResponseUsage

- `input_tokens` (integer, required) — Number of input tokens.
- `input_tokens_details` (ResponseInputTokensDetails, required) — Detailed input-token usage.
- `output_tokens` (integer, required) — Number of generated output tokens.
- `output_tokens_details` (ResponseOutputTokensDetails, required) — Detailed output-token usage.
- `total_tokens` (integer, required) — Total input and output tokens.
- `server_tool_use` (map from string to long, optional)

### OpenAIErrorDetails

- `message` (string, required)
- `type` (string, required)
- `code` (string, optional, nullable)

### ResponseReasoningParamEffort

Reasoning effort: `default`, `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max`. Some models also support numeric reasoning effort. Check the model's [Mixlayer documentation page](/models) for supported values and ranges. Omit for the model default. See [Reasoning](/reasoning#model-mappings) for model-specific mappings and unsupported values.

### ResponseTextFormatParam

### ResponseFunctionToolChoice

- `name` (string, required) — Function name to force.
- `type` (enum, required)
  - Allowed values: `function`

### ResponseToolParam0

- `name` (string, required) — Function name. Must be 1-64 ASCII letters, numbers, underscores, or hyphens.
- `type` (enum, required)
  - Allowed values: `function`
- `allowed_callers` (list of string, optional, nullable) — Callers permitted to invoke the function.
- `defer_loading` (boolean, optional, nullable) — Whether the function definition is deferred until tool search loads it.
- `description` (string, optional, nullable) — Description of what the function does.
- `output_schema` (any, optional) — JSON Schema describing the function output.
- `parameters` (any, optional) — JSON Schema describing the function arguments.
- `strict` (boolean, optional, nullable) — Whether generated arguments must strictly match the schema.

### ResponseToolParam1

Namespace tool supplied in a Responses request.

- `description` (string, required) — Description of the domain covered by the namespace.
- `name` (string, required) — Namespace name. Must be 1-64 ASCII letters, numbers, underscores, or hyphens.
- `tools` (list of ResponseNamespaceMemberParam, required) — Function tools contained in the namespace.
- `type` (enum, required)
  - Allowed values: `namespace`

### ResponseToolParam2

Validated options for one hosted web-search tool.

- `type` (enum, required)
  - Allowed values: `web_search`
- `category` (enum, optional, nullable) — Exa content category accepted by the public web-search options.
  - Allowed values: `company`, `people`, `research paper`, `news`, `personal site`, `financial report`
- `filters` (WebSearchFilters, optional, nullable) — Domain allow/block filters for hosted web search.
- `max_characters` (integer, optional)
- `max_results` (integer, optional)
- `user_location` (WebSearchUserLocation, optional, nullable) — Approximate location accepted by the Responses API.

### ResponseToolParam3

- `type` (enum, required)
  - Allowed values: `unsupported`

### ResponseOutputItem0

- `content` (list of ResponseContentPart, required) — Generated message content.
- `id` (string, required) — Unique output item identifier.
- `role` (string, required) — Message author role, always `assistant`.
- `status` (string, required) — Output item status.
- `type` (enum, required)
  - Allowed values: `message`

### ResponseOutputItem1

- `arguments` (string, required) — Generated function arguments serialized as JSON.
- `call_id` (string, required) — Tool call correlation ID.
- `id` (string, required) — Unique output item identifier.
- `name` (string, required) — Function name.
- `status` (string, required) — Output item status.
- `type` (enum, required)
  - Allowed values: `function_call`
- `namespace` (string, optional, nullable) — Namespace containing the function, when applicable.

### ResponseOutputItem2

- `id` (string, required) — Unique output item identifier.
- `summary` (list of ResponseContentPart, required) — Generated reasoning summaries.
- `type` (enum, required)
  - Allowed values: `reasoning`
- `content` (list of ResponseContentPart, optional, nullable) — Generated reasoning content.

### ResponseOutputItem3

- `action` (ResponseWebSearchAction, required) — Search action returned inside a Responses web-search call item.
- `id` (string, required)
- `status` (string, required)
- `type` (enum, required)
  - Allowed values: `web_search_call`

### ResponseTextFormatField

- `type` (enum, required) — Output format type: `text`, `json_object`, or `json_schema`.
  - Allowed values: `text`, `json_object`, `json_schema`
- `name` (string, optional, nullable) — Name of the JSON Schema output format.
- `schema` (any, optional) — JSON Schema the output must conform to.
- `strict` (boolean, optional, nullable) — Whether the JSON Schema is enforced strictly.

### ResponseTool0

- `name` (string, required) — Function name.
- `type` (enum, required)
  - Allowed values: `function`
- `defer_loading` (boolean, optional, nullable) — Whether the function definition is deferred until tool search loads it.
- `description` (string, optional, nullable) — Description of what the function does.
- `parameters` (any, optional) — JSON Schema describing the function arguments.
- `strict` (boolean, optional, nullable) — Whether generated arguments must strictly match the schema.

### ResponseTool1

Namespace grouping related function tools.

- `description` (string, required) — Description of the domain covered by the namespace.
- `name` (string, required) — Namespace name.
- `tools` (list of ResponseNamespaceMember, required) — Function tools contained in the namespace.
- `type` (enum, required)
  - Allowed values: `namespace`

### ResponseTool2

Hosted web-search tool and its options.

- `type` (enum, required)
  - Allowed values: `web_search`
- `category` (enum, optional, nullable) — Exa content category accepted by the public web-search options.
  - Allowed values: `company`, `people`, `research paper`, `news`, `personal site`, `financial report`
- `filters` (WebSearchFilters, optional, nullable) — Domain allow/block filters for hosted web search.
- `max_characters` (integer, optional)
- `max_results` (integer, optional)
- `user_location` (WebSearchUserLocation, optional, nullable) — Approximate location accepted by the Responses API.

### ResponseInputTokensDetails

- `cached_tokens` (integer, required) — Number of cached input tokens.

### ResponseOutputTokensDetails

Breakdown of generated output tokens, including reasoning when the backend reports it.

- `reasoning_tokens` (integer, optional, nullable) — Committed reasoning-stage tokens, including generated delimiters; absent if unknown.

### ResponseTextFormatParam0

- `type` (enum, required)
  - Allowed values: `text`

### ResponseTextFormatParam1

- `type` (enum, required)
  - Allowed values: `json_object`

### ResponseTextFormatParam2

- `name` (string, required) — Name of the output format.
- `schema` (any, required) — JSON Schema the output must conform to.
- `type` (enum, required)
  - Allowed values: `json_schema`
- `strict` (boolean, optional, nullable) — Whether the schema is enforced strictly.

### ResponseTextFormatParam3

- `type` (enum, required)
  - Allowed values: `Unsupported`

### ResponseNamespaceMemberParam

Tool definition nested inside a namespace request.

### WebSearchFilters

Domain allow/block filters for hosted web search.

- `allowed_domains` (list of string, optional)
- `blocked_domains` (list of string, optional)

### WebSearchUserLocation

Approximate location accepted by the Responses API.

- `type` (string, required)
- `city` (string, optional, nullable)
- `country` (string, optional, nullable)
- `region` (string, optional, nullable)
- `timezone` (string, optional, nullable)

### ResponseContentPart

### ResponseWebSearchAction

Search action returned inside a Responses web-search call item.

- `query` (string, required)
- `type` (string, required)
- `sources` (list of WebSearchSource, optional, nullable)

### ResponseNamespaceMember

Function tool echoed inside a namespace response definition.

### ResponseNamespaceMemberParam0

- `name` (string, required) — Function name. Must be 1-64 ASCII letters, numbers, underscores, or hyphens.
- `type` (enum, required)
  - Allowed values: `function`
- `allowed_callers` (list of string, optional, nullable) — Callers permitted to invoke the function.
- `defer_loading` (boolean, optional, nullable) — Whether the function definition is deferred until tool search loads it.
- `description` (string, optional, nullable) — Description of what the function does.
- `output_schema` (any, optional) — JSON Schema describing the function output.
- `parameters` (any, optional) — JSON Schema describing the function arguments.
- `strict` (boolean, optional, nullable) — Whether generated arguments must strictly match the schema.

### ResponseNamespaceMemberParam1

- `type` (enum, required)
  - Allowed values: `unsupported`

### ResponseContentPart0

- `annotations` (list of any, required) — Annotations attached to the output text.
- `text` (string, required) — Generated output text.
- `type` (enum, required)
  - Allowed values: `output_text`

### ResponseContentPart1

- `text` (string, required) — Generated reasoning text.
- `type` (enum, required)
  - Allowed values: `reasoning_text`

### WebSearchSource

Public source metadata returned with a hosted search.

- `title` (string, required)
- `url` (string, required)
- `type` (string, optional, nullable)

### ResponseNamespaceMember0

- `name` (string, required) — Function name within the namespace.
- `parameters` (any, required) — JSON Schema describing the function arguments.
- `type` (enum, required)
  - Allowed values: `function`
- `defer_loading` (boolean, optional, nullable) — Whether the definition is deferred until tool search loads it.
- `description` (string, optional, nullable) — Description of what the function does.
- `strict` (boolean, optional, nullable) — Whether generated arguments must strictly match the schema.

## Examples

**Request**

```json
{
  "input": "string",
  "model": "string"
}
```

**Response**

```json
{
  "background": true,
  "created_at": 1,
  "frequency_penalty": 1.1,
  "id": "string",
  "metadata": null,
  "model": "string",
  "object": "response",
  "output": [
    {
      "content": [
        {
          "annotations": [
            null
          ],
          "text": "string",
          "type": "output_text"
        }
      ],
      "id": "string",
      "role": "string",
      "status": "string",
      "type": "message"
    }
  ],
  "output_text": "string",
  "parallel_tool_calls": true,
  "presence_penalty": 1.1,
  "reasoning": {
    "effort": "string",
    "summary": null
  },
  "service_tier": "default",
  "status": "in_progress",
  "store": true,
  "text": {
    "format": {
      "type": "text",
      "name": "string",
      "schema": null,
      "strict": true
    }
  },
  "tool_choice": null,
  "tools": [
    {
      "defer_loading": true,
      "description": "string",
      "name": "string",
      "parameters": null,
      "strict": true,
      "type": "function"
    }
  ],
  "top_logprobs": 1,
  "top_p": 1.1,
  "truncation": "disabled",
  "completed_at": 1,
  "error": null,
  "incomplete_details": null,
  "instructions": "string",
  "max_output_tokens": 1,
  "max_tool_calls": 1,
  "previous_response_id": "string",
  "prompt_cache_key": "string",
  "safety_identifier": "string",
  "temperature": 1.1,
  "usage": null
}
```

**SDK Code**

```python
import requests

url = "https://mixlayer.ai/v1/responses"

payload = {
    "input": "string",
    "model": "string"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://mixlayer.ai/v1/responses';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"input":"string","model":"string"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://mixlayer.ai/v1/responses"

	payload := strings.NewReader("{\n  \"input\": \"string\",\n  \"model\": \"string\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://mixlayer.ai/v1/responses")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"input\": \"string\",\n  \"model\": \"string\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://mixlayer.ai/v1/responses")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": \"string\",\n  \"model\": \"string\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://mixlayer.ai/v1/responses', [
  'body' => '{
  "input": "string",
  "model": "string"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```