---
title: "Create a response"
description: "Creates an OpenAI-compatible response through Respan. Choose the OpenAI, Azure, Perplexity, or Bedrock example. The OpenAI and Perplexity examples use Respan-managed routing when the model is available on credits; provider credentials can also be stored in Settings > Providers or supplied in respan_params.credential_override. For Azure, replace YOUR_AZURE_DEPLOYMENT, YOUR_RESOURCE and PROVIDER_API_KEY with your Azure deployment and credentials. Bedrock Responses requires your own AWS Bedrock credentials configured in Respan (BYOK); Respan credits are not supported for this route. Successful responses include X-Respan-Log-Id and are logged with the provider model and cost."
---

<a id="playground-button:docs/apis/gateway/create-response"></a>

**POST** `https://api.respan.ai/api/responses`

Creates an OpenAI-compatible response through Respan. Choose the OpenAI, Azure, Perplexity, or Bedrock example. The OpenAI and Perplexity examples use Respan-managed routing when the model is available on credits; provider credentials can also be stored in Settings &gt; Providers or supplied in respan_params.credential_override. For Azure, replace YOUR_AZURE_DEPLOYMENT, YOUR_RESOURCE and PROVIDER_API_KEY with your Azure deployment and credentials. Bedrock Responses requires your own AWS Bedrock credentials configured in Respan (BYOK); Respan credits are not supported for this route. Successful responses include X-Respan-Log-Id and are logged with the provider model and cost.

## Servers

`https://api.respan.ai`: Respan API Server

<a id="request.auth"></a>

## Authentication

<a id="request.auth.Authorization"></a>

### RespanApiKey

Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer &lt;RESPAN_API_KEY&gt;. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -&gt; Providers or respan_params.credential_override in the request body, not in this authentication field.

HTTP scheme: `bearer`; format: `Respan API key`.


```http
Authorization: Bearer $RESPAN_API_KEY
```


<a id="request.query"></a>

## Query parameters


| Parameter | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| <a id="request.query.format"></a>`format` | `string` | Optional | Allowed: `"json"`, `"txt"` |


<a id="request"></a>

## Request body

A request body is required.

### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Required body | OpenAI Responses API request. Standard Responses fields are accepted. Perplexity extensions apply to perplexity/ models. Respan cache controls and `customer_identifier` may be sent at the request root or under `respan_params`; nested values win when both are present.<br />Additional properties are allowed |
| <a id="request.body.model"></a>`model` | `string` | Optional | OpenAI: use a supported model such as gpt-6-luna. Azure: use azure/&lt;your-deployment-name&gt;. Perplexity: use a provider-prefixed model, such as perplexity/sonar. Bedrock: use a bedrock-prefixed inference profile, such as bedrock/us.openai.gpt-6.1-sol. |
| <a id="request.body.input"></a>`input` | `string or array<any>` | Required in parent | Text or structured input for the response. |
| `input (oneOf 1)` | `string` | Schema variant | - |
| `input (oneOf 2)` | `array<any>` | Schema variant | - |
| `input (oneOf 2)[]` | `any` | Array item | - |
| <a id="request.body.stream"></a>`stream` | `boolean` | Optional | Return Responses API server-sent events when true.<br />Default: `false` |
| <a id="request.body.preset"></a>`preset` | `string` | Optional | Perplexity Agent API preset, such as `medium`. Send it with `model`: a preset alone fails Respan's model validation. |
| <a id="request.body.max_steps"></a>`max_steps` | `integer` | Optional | Maximum Perplexity agent steps.<br />Minimum: `1` |
| <a id="request.body.language_preference"></a>`language_preference` | `string` | Optional | Preferred response language for Perplexity Agent API. |
| <a id="request.body.response_format"></a>`response_format` | `object` | Optional | Perplexity Agent API structured response configuration. |
| <a id="request.body.skills"></a>`skills` | `array<any>` | Optional | Perplexity Agent API skills. |
| `skills[]` | `any` | Array item | - |
| <a id="request.body.tools"></a>`tools` | `array<any>` | Optional | Response tools. Perplexity supports web_search with filters such as search_domain_filter. |
| `tools[]` | `any` | Array item | - |
| <a id="request.body.respan_params"></a>`respan_params` | `object` | Optional | Respan metadata, prompt configuration, customer identifiers, provider credentials, and other gateway parameters. |
| `respan_params.credential_override` | `object` | Optional | Request-scoped provider credentials. Named examples prefill the correct selector; keep that selector and replace only its credential values. OpenAI and Azure selectors exactly match model. Perplexity uses an empty-string selector because its credential is provider-scoped. |
| `respan_params.credential_override.<key>` | `object` | Map value | Additional properties are allowed |
| `respan_params.credential_override.<key>.api_key` | `string` | Optional | API key for the selected upstream provider, not your Respan API key. Enter the Respan key in the Authorization control.<br />Format: `password`<br />Write only |
| `respan_params.credential_override.<key>.api_base` | `string` | Optional | Azure OpenAI resource endpoint, for example https://YOUR_RESOURCE.openai.azure.com.<br />Format: `uri` |
| `respan_params.credential_override.<key>.api_version` | `string` | Optional | Azure OpenAI API version. The Azure example prefills 2025-04-01-preview, which supports the Responses API. |
| `respan_params.cache_enabled` | `boolean` | Optional | Enable response caching for this request. |
| `respan_params.cache_ttl` | `number` | Optional | Cache lifetime in seconds. A response stored without `cache_ttl` is served from the cache for at most 30 minutes. |
| `respan_params.cache_options` | `object` | Optional | Additional properties are not allowed |
| `respan_params.cache_options.cache_by_customer` | `boolean` | Optional | - |
| `respan_params.cache_options.is_cached_by_model` | `boolean` | Optional | - |
| `respan_params.cache_options.omit_log` | `boolean` | Optional | - |
| `respan_params.customer_identifier` | `string` | Optional | End-customer identifier used for logging and optional cache partitioning. |
| <a id="request.body.cache_enabled"></a>`cache_enabled` | `boolean` | Optional | Enable response caching for this request. |
| <a id="request.body.cache_ttl"></a>`cache_ttl` | `number` | Optional | Cache lifetime in seconds. A response stored without `cache_ttl` is served from the cache for at most 30 minutes. |
| <a id="request.body.cache_options"></a>`cache_options` | `object` | Optional | Additional properties are not allowed |
| `cache_options.cache_by_customer` | `boolean` | Optional | - |
| `cache_options.is_cached_by_model` | `boolean` | Optional | - |
| `cache_options.omit_log` | `boolean` | Optional | - |
| <a id="request.body.customer_identifier"></a>`customer_identifier` | `string` | Optional | End-customer identifier used for logging and optional cache partitioning. |


<details class="api-schema-source">
<summary>OpenAPI request schema</summary>


```json
{
  "type": "object",
  "description": "OpenAI Responses API request. Standard Responses fields are accepted. Perplexity extensions apply to perplexity/ models. Respan cache controls and `customer_identifier` may be sent at the request root or under `respan_params`; nested values win when both are present.",
  "additionalProperties": true,
  "properties": {
    "model": {
      "type": "string",
      "description": "OpenAI: use a supported model such as gpt-6-luna. Azure: use azure/<your-deployment-name>. Perplexity: use a provider-prefixed model, such as perplexity/sonar. Bedrock: use a bedrock-prefixed inference profile, such as bedrock/us.openai.gpt-6.1-sol."
    },
    "input": {
      "description": "Text or structured input for the response.",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {}
        }
      ]
    },
    "stream": {
      "type": "boolean",
      "default": false,
      "description": "Return Responses API server-sent events when true."
    },
    "preset": {
      "type": "string",
      "description": "Perplexity Agent API preset, such as `medium`. Send it with `model`: a preset alone fails Respan's model validation."
    },
    "max_steps": {
      "type": "integer",
      "minimum": 1,
      "description": "Maximum Perplexity agent steps."
    },
    "language_preference": {
      "type": "string",
      "description": "Preferred response language for Perplexity Agent API."
    },
    "response_format": {
      "type": "object",
      "description": "Perplexity Agent API structured response configuration."
    },
    "skills": {
      "type": "array",
      "description": "Perplexity Agent API skills.",
      "items": {}
    },
    "tools": {
      "type": "array",
      "description": "Response tools. Perplexity supports web_search with filters such as search_domain_filter.",
      "items": {}
    },
    "respan_params": {
      "type": "object",
      "description": "Respan metadata, prompt configuration, customer identifiers, provider credentials, and other gateway parameters.",
      "properties": {
        "credential_override": {
          "type": "object",
          "description": "Request-scoped provider credentials. Named examples prefill the correct selector; keep that selector and replace only its credential values. OpenAI and Azure selectors exactly match model. Perplexity uses an empty-string selector because its credential is provider-scoped.",
          "additionalProperties": {
            "type": "object",
            "additionalProperties": true,
            "properties": {
              "api_key": {
                "type": "string",
                "format": "password",
                "writeOnly": true,
                "description": "API key for the selected upstream provider, not your Respan API key. Enter the Respan key in the Authorization control."
              },
              "api_base": {
                "type": "string",
                "format": "uri",
                "description": "Azure OpenAI resource endpoint, for example https://YOUR_RESOURCE.openai.azure.com."
              },
              "api_version": {
                "type": "string",
                "description": "Azure OpenAI API version. The Azure example prefills 2025-04-01-preview, which supports the Responses API."
              }
            }
          }
        },
        "cache_enabled": {
          "type": "boolean",
          "description": "Enable response caching for this request."
        },
        "cache_ttl": {
          "type": "number",
          "description": "Cache lifetime in seconds. A response stored without `cache_ttl` is served from the cache for at most 30 minutes."
        },
        "cache_options": {
          "type": "object",
          "properties": {
            "cache_by_customer": {
              "type": "boolean"
            },
            "is_cached_by_model": {
              "type": "boolean"
            },
            "omit_log": {
              "type": "boolean"
            }
          },
          "additionalProperties": false
        },
        "customer_identifier": {
          "type": "string",
          "description": "End-customer identifier used for logging and optional cache partitioning."
        }
      }
    },
    "cache_enabled": {
      "type": "boolean",
      "description": "Enable response caching for this request."
    },
    "cache_ttl": {
      "type": "number",
      "description": "Cache lifetime in seconds. A response stored without `cache_ttl` is served from the cache for at most 30 minutes."
    },
    "cache_options": {
      "type": "object",
      "properties": {
        "cache_by_customer": {
          "type": "boolean"
        },
        "is_cached_by_model": {
          "type": "boolean"
        },
        "omit_log": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "customer_identifier": {
      "type": "string",
      "description": "End-customer identifier used for logging and optional cache partitioning."
    }
  },
  "required": [
    "input"
  ]
}
```

</details>

## Examples

### openai

#### Headers


```json
{
  "Authorization": "Bearer YOUR_RESPAN_API_KEY"
}
```


#### Request


```json
{
  "model": "gpt-6-luna",
  "input": "Reply with exactly ok.",
  "max_output_tokens": 32,
  "reasoning": {
    "effort": "none"
  },
  "stream": false
}
```


#### Response


```json
{
  "body": {
    "id": "resp_openai_example",
    "model": "gpt-6-luna",
    "output": []
  }
}
```


#### cURL


```bash
curl --request POST 'https://api.respan.ai/api/responses' \
  --header "Authorization: Bearer $RESPAN_API_KEY" \
  --header 'Content-Type: application/json' \
  --data @- <<'JSON'
{
  "model": "gpt-6-luna",
  "input": "Reply with exactly ok.",
  "max_output_tokens": 32,
  "reasoning": {
    "effort": "none"
  },
  "stream": false
}
JSON
```


<details>
<summary>Python</summary>



```python
import json
import os
import urllib.request

payload = json.loads(r'''{
  "model": "gpt-6-luna",
  "input": "Reply with exactly ok.",
  "max_output_tokens": 32,
  "reasoning": {
    "effort": "none"
  },
  "stream": false
}''')

request = urllib.request.Request(
    "https://api.respan.ai/api/responses",
    data=json.dumps(payload).encode(),
    headers={
        "Authorization": f"Bearer {os.environ['RESPAN_API_KEY']}",
        "Content-Type": "application/json",
    },
    method="POST",
)
with urllib.request.urlopen(request) as response:
    print(json.load(response))
```


</details>

<details>
<summary>TypeScript</summary>



```typescript
const response = await fetch("https://api.respan.ai/api/responses", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.RESPAN_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "gpt-6-luna",
    "input": "Reply with exactly ok.",
    "max_output_tokens": 32,
    "reasoning": {
      "effort": "none"
    },
    "stream": false
  }),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
```


</details>

<details>
<summary>Python SDK (respan-api)</summary>



```python
import json
import os
from respan import RespanClient

client = RespanClient(respan_api_key=os.environ["RESPAN_API_KEY"])
payload = json.loads(r'''{
  "model": "gpt-6-luna",
  "input": "Reply with exactly ok.",
  "max_output_tokens": 32,
  "reasoning": {
    "effort": "none"
  },
  "stream": false
}''')
response = client.gateway.create_response(
    **payload,
)
print(response)
```


</details>

<details>
<summary>TypeScript SDK (@respan/respan-api)</summary>



```typescript
import { RespanClient } from "@respan/respan-api";

const apiKey = process.env.RESPAN_API_KEY!;
const client = new RespanClient({
  respanApiKey: apiKey,
  authorization: `Bearer ${apiKey}`,
});
const response = await client.gateway.createResponse({
  "model": "gpt-6-luna",
  "input": "Reply with exactly ok.",
  "max_output_tokens": 32,
  "reasoning": {
    "effort": "none"
  },
  "stream": false
});
console.log(response);
```


</details>

### azure

#### Headers


```json
{
  "Authorization": "Bearer YOUR_RESPAN_API_KEY"
}
```


#### Request


```json
{
  "model": "azure/YOUR_AZURE_DEPLOYMENT",
  "input": "Summarize the benefits of retrieval-augmented generation.",
  "stream": false,
  "respan_params": {
    "credential_override": {
      "azure/YOUR_AZURE_DEPLOYMENT": {
        "api_key": "PROVIDER_API_KEY",
        "api_base": "https://YOUR_RESOURCE.openai.azure.com",
        "api_version": "2025-04-01-preview"
      }
    }
  }
}
```


#### Response


```json
{
  "body": {
    "id": "resp_azure_example",
    "model": "azure/YOUR_AZURE_DEPLOYMENT",
    "output": []
  }
}
```


#### cURL


```bash
curl --request POST 'https://api.respan.ai/api/responses' \
  --header "Authorization: Bearer $RESPAN_API_KEY" \
  --header 'Content-Type: application/json' \
  --data @- <<'JSON'
{
  "model": "azure/YOUR_AZURE_DEPLOYMENT",
  "input": "Summarize the benefits of retrieval-augmented generation.",
  "stream": false,
  "respan_params": {
    "credential_override": {
      "azure/YOUR_AZURE_DEPLOYMENT": {
        "api_key": "PROVIDER_API_KEY",
        "api_base": "https://YOUR_RESOURCE.openai.azure.com",
        "api_version": "2025-04-01-preview"
      }
    }
  }
}
JSON
```


<details>
<summary>Python</summary>



```python
import json
import os
import urllib.request

payload = json.loads(r'''{
  "model": "azure/YOUR_AZURE_DEPLOYMENT",
  "input": "Summarize the benefits of retrieval-augmented generation.",
  "stream": false,
  "respan_params": {
    "credential_override": {
      "azure/YOUR_AZURE_DEPLOYMENT": {
        "api_key": "PROVIDER_API_KEY",
        "api_base": "https://YOUR_RESOURCE.openai.azure.com",
        "api_version": "2025-04-01-preview"
      }
    }
  }
}''')

request = urllib.request.Request(
    "https://api.respan.ai/api/responses",
    data=json.dumps(payload).encode(),
    headers={
        "Authorization": f"Bearer {os.environ['RESPAN_API_KEY']}",
        "Content-Type": "application/json",
    },
    method="POST",
)
with urllib.request.urlopen(request) as response:
    print(json.load(response))
```


</details>

<details>
<summary>TypeScript</summary>



```typescript
const response = await fetch("https://api.respan.ai/api/responses", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.RESPAN_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "azure/YOUR_AZURE_DEPLOYMENT",
    "input": "Summarize the benefits of retrieval-augmented generation.",
    "stream": false,
    "respan_params": {
      "credential_override": {
        "azure/YOUR_AZURE_DEPLOYMENT": {
          "api_key": "PROVIDER_API_KEY",
          "api_base": "https://YOUR_RESOURCE.openai.azure.com",
          "api_version": "2025-04-01-preview"
        }
      }
    }
  }),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
```


</details>

<details>
<summary>Python SDK (respan-api)</summary>



```python
import json
import os
from respan import RespanClient

client = RespanClient(respan_api_key=os.environ["RESPAN_API_KEY"])
payload = json.loads(r'''{
  "model": "azure/YOUR_AZURE_DEPLOYMENT",
  "input": "Summarize the benefits of retrieval-augmented generation.",
  "stream": false,
  "respan_params": {
    "credential_override": {
      "azure/YOUR_AZURE_DEPLOYMENT": {
        "api_key": "PROVIDER_API_KEY",
        "api_base": "https://YOUR_RESOURCE.openai.azure.com",
        "api_version": "2025-04-01-preview"
      }
    }
  }
}''')
response = client.gateway.create_response(
    **payload,
)
print(response)
```


</details>

<details>
<summary>TypeScript SDK (@respan/respan-api)</summary>



```typescript
import { RespanClient } from "@respan/respan-api";

const apiKey = process.env.RESPAN_API_KEY!;
const client = new RespanClient({
  respanApiKey: apiKey,
  authorization: `Bearer ${apiKey}`,
});
const response = await client.gateway.createResponse({
  "model": "azure/YOUR_AZURE_DEPLOYMENT",
  "input": "Summarize the benefits of retrieval-augmented generation.",
  "stream": false,
  "respan_params": {
    "credential_override": {
      "azure/YOUR_AZURE_DEPLOYMENT": {
        "api_key": "PROVIDER_API_KEY",
        "api_base": "https://YOUR_RESOURCE.openai.azure.com",
        "api_version": "2025-04-01-preview"
      }
    }
  }
});
console.log(response);
```


</details>

### perplexity

#### Headers


```json
{
  "Authorization": "Bearer YOUR_RESPAN_API_KEY"
}
```


#### Request


```json
{
  "model": "perplexity/sonar",
  "input": "Reply with exactly ok.",
  "max_steps": 1,
  "max_output_tokens": 32,
  "stream": false
}
```


#### Response


```json
{
  "body": {
    "id": "resp_perplexity_example",
    "model": "perplexity/sonar",
    "output": []
  }
}
```


#### cURL


```bash
curl --request POST 'https://api.respan.ai/api/responses' \
  --header "Authorization: Bearer $RESPAN_API_KEY" \
  --header 'Content-Type: application/json' \
  --data @- <<'JSON'
{
  "model": "perplexity/sonar",
  "input": "Reply with exactly ok.",
  "max_steps": 1,
  "max_output_tokens": 32,
  "stream": false
}
JSON
```


<details>
<summary>Python</summary>



```python
import json
import os
import urllib.request

payload = json.loads(r'''{
  "model": "perplexity/sonar",
  "input": "Reply with exactly ok.",
  "max_steps": 1,
  "max_output_tokens": 32,
  "stream": false
}''')

request = urllib.request.Request(
    "https://api.respan.ai/api/responses",
    data=json.dumps(payload).encode(),
    headers={
        "Authorization": f"Bearer {os.environ['RESPAN_API_KEY']}",
        "Content-Type": "application/json",
    },
    method="POST",
)
with urllib.request.urlopen(request) as response:
    print(json.load(response))
```


</details>

<details>
<summary>TypeScript</summary>



```typescript
const response = await fetch("https://api.respan.ai/api/responses", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.RESPAN_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "perplexity/sonar",
    "input": "Reply with exactly ok.",
    "max_steps": 1,
    "max_output_tokens": 32,
    "stream": false
  }),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
```


</details>

<details>
<summary>Python SDK (respan-api)</summary>



```python
import json
import os
from respan import RespanClient

client = RespanClient(respan_api_key=os.environ["RESPAN_API_KEY"])
payload = json.loads(r'''{
  "model": "perplexity/sonar",
  "input": "Reply with exactly ok.",
  "max_steps": 1,
  "max_output_tokens": 32,
  "stream": false
}''')
response = client.gateway.create_response(
    **payload,
)
print(response)
```


</details>

<details>
<summary>TypeScript SDK (@respan/respan-api)</summary>



```typescript
import { RespanClient } from "@respan/respan-api";

const apiKey = process.env.RESPAN_API_KEY!;
const client = new RespanClient({
  respanApiKey: apiKey,
  authorization: `Bearer ${apiKey}`,
});
const response = await client.gateway.createResponse({
  "model": "perplexity/sonar",
  "input": "Reply with exactly ok.",
  "max_steps": 1,
  "max_output_tokens": 32,
  "stream": false
});
console.log(response);
```


</details>

### bedrock

Requires your own AWS Bedrock credentials configured in Respan (BYOK). Respan credits are not supported.

#### Headers


```json
{
  "Authorization": "Bearer YOUR_RESPAN_API_KEY"
}
```


#### Request


```json
{
  "model": "bedrock/us.openai.gpt-6.1-sol",
  "input": "Hello"
}
```


#### cURL


```bash
curl --request POST 'https://api.respan.ai/api/responses' \
  --header "Authorization: Bearer $RESPAN_API_KEY" \
  --header 'Content-Type: application/json' \
  --data @- <<'JSON'
{
  "model": "bedrock/us.openai.gpt-6.1-sol",
  "input": "Hello"
}
JSON
```


<details>
<summary>Python</summary>



```python
import json
import os
import urllib.request

payload = json.loads(r'''{
  "model": "bedrock/us.openai.gpt-6.1-sol",
  "input": "Hello"
}''')

request = urllib.request.Request(
    "https://api.respan.ai/api/responses",
    data=json.dumps(payload).encode(),
    headers={
        "Authorization": f"Bearer {os.environ['RESPAN_API_KEY']}",
        "Content-Type": "application/json",
    },
    method="POST",
)
with urllib.request.urlopen(request) as response:
    print(json.load(response))
```


</details>

<details>
<summary>TypeScript</summary>



```typescript
const response = await fetch("https://api.respan.ai/api/responses", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.RESPAN_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "bedrock/us.openai.gpt-6.1-sol",
    "input": "Hello"
  }),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
```


</details>

<details>
<summary>Python SDK (respan-api)</summary>



```python
import json
import os
from respan import RespanClient

client = RespanClient(respan_api_key=os.environ["RESPAN_API_KEY"])
payload = json.loads(r'''{
  "model": "bedrock/us.openai.gpt-6.1-sol",
  "input": "Hello"
}''')
response = client.gateway.create_response(
    **payload,
)
print(response)
```


</details>

<details>
<summary>TypeScript SDK (@respan/respan-api)</summary>



```typescript
import { RespanClient } from "@respan/respan-api";

const apiKey = process.env.RESPAN_API_KEY!;
const client = new RespanClient({
  respanApiKey: apiKey,
  authorization: `Bearer ${apiKey}`,
});
const response = await client.gateway.createResponse({
  "model": "bedrock/us.openai.gpt-6.1-sol",
  "input": "Hello"
});
console.log(response);
```


</details>

<a id="response"></a>

## Responses

### 200

Response object or event stream from the selected Responses upstream.

<a id="response.response-header"></a>

#### Response headers


| Parameter | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| <a id="response.response-header.X-Respan-Log-Id"></a>`X-Respan-Log-Id` | `string` | Optional | Unique ID of the Respan request log. |


#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | Additional properties are allowed |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "additionalProperties": true
}
```

</details>

<a id="response.error"></a>

### 400

Invalid request, provider route configuration, or upstream provider request. Include `input` and a route-appropriate `model`.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `error` | `object` | Required in parent | - |
| `error.message` | `string` | Required in parent | - |
| `error.type` | `string` | Required in parent | - |
| `error.param` | `any or null` | Optional | - |
| `error.code` | `any or null` | Optional | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "error"
  ],
  "properties": {
    "error": {
      "type": "object",
      "required": [
        "message",
        "type"
      ],
      "properties": {
        "message": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "param": {
          "nullable": true
        },
        "code": {
          "nullable": true
        }
      }
    }
  }
}
```

</details>

### 401

No usable provider credential, or the provider rejected it. Configure the provider in Settings › Providers, or pass `respan_params.credential_override`.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `error` | `object` | Required in parent | - |
| `error.message` | `string` | Required in parent | - |
| `error.type` | `string` | Required in parent | - |
| `error.param` | `any or null` | Optional | - |
| `error.code` | `any or null` | Optional | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "error"
  ],
  "properties": {
    "error": {
      "type": "object",
      "required": [
        "message",
        "type"
      ],
      "properties": {
        "message": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "param": {
          "nullable": true
        },
        "code": {
          "nullable": true
        }
      }
    }
  }
}
```

</details>

### 403

The API key is missing, invalid or expired.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Required in parent | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "detail"
  ],
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}
```


### 422

Request validation failed.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `error` | `object` | Required in parent | - |
| `error.message` | `string` | Required in parent | - |
| `error.type` | `string` | Required in parent | - |
| `error.param` | `any or null` | Optional | - |
| `error.code` | `any or null` | Optional | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "error"
  ],
  "properties": {
    "error": {
      "type": "object",
      "required": [
        "message",
        "type"
      ],
      "properties": {
        "message": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "param": {
          "nullable": true
        },
        "code": {
          "nullable": true
        }
      }
    }
  }
}
```

</details>

## OpenAPI source

The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.

<!-- openapi-operation:start -->
<details class="api-schema-source">
<summary>OpenAPI operation</summary>


```json
{
  "operationId": "createResponse",
  "summary": "Create a response",
  "description": "Creates an OpenAI-compatible response through Respan. Choose the OpenAI, Azure, Perplexity, or Bedrock example. The OpenAI and Perplexity examples use Respan-managed routing when the model is available on credits; provider credentials can also be stored in Settings > Providers or supplied in respan_params.credential_override. For Azure, replace YOUR_AZURE_DEPLOYMENT, YOUR_RESOURCE and PROVIDER_API_KEY with your Azure deployment and credentials. Bedrock Responses requires your own AWS Bedrock credentials configured in Respan (BYOK); Respan credits are not supported for this route. Successful responses include X-Respan-Log-Id and are logged with the provider model and cost.",
  "x-fern-examples": [
    {
      "name": "openai",
      "headers": {
        "Authorization": "Bearer YOUR_RESPAN_API_KEY"
      },
      "request": {
        "model": "gpt-6-luna",
        "input": "Reply with exactly ok.",
        "max_output_tokens": 32,
        "reasoning": {
          "effort": "none"
        },
        "stream": false
      },
      "response": {
        "body": {
          "id": "resp_openai_example",
          "model": "gpt-6-luna",
          "output": []
        }
      }
    },
    {
      "name": "azure",
      "headers": {
        "Authorization": "Bearer YOUR_RESPAN_API_KEY"
      },
      "request": {
        "model": "azure/YOUR_AZURE_DEPLOYMENT",
        "input": "Summarize the benefits of retrieval-augmented generation.",
        "stream": false,
        "respan_params": {
          "credential_override": {
            "azure/YOUR_AZURE_DEPLOYMENT": {
              "api_key": "PROVIDER_API_KEY",
              "api_base": "https://YOUR_RESOURCE.openai.azure.com",
              "api_version": "2025-04-01-preview"
            }
          }
        }
      },
      "response": {
        "body": {
          "id": "resp_azure_example",
          "model": "azure/YOUR_AZURE_DEPLOYMENT",
          "output": []
        }
      }
    },
    {
      "name": "perplexity",
      "headers": {
        "Authorization": "Bearer YOUR_RESPAN_API_KEY"
      },
      "request": {
        "model": "perplexity/sonar",
        "input": "Reply with exactly ok.",
        "max_steps": 1,
        "max_output_tokens": 32,
        "stream": false
      },
      "response": {
        "body": {
          "id": "resp_perplexity_example",
          "model": "perplexity/sonar",
          "output": []
        }
      }
    },
    {
      "name": "bedrock",
      "description": "Requires your own AWS Bedrock credentials configured in Respan (BYOK). Respan credits are not supported.",
      "headers": {
        "Authorization": "Bearer YOUR_RESPAN_API_KEY"
      },
      "request": {
        "model": "bedrock/us.openai.gpt-6.1-sol",
        "input": "Hello"
      }
    }
  ],
  "parameters": [
    {
      "in": "query",
      "name": "format",
      "schema": {
        "type": "string",
        "enum": [
          "json",
          "txt"
        ]
      }
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "description": "OpenAI Responses API request. Standard Responses fields are accepted. Perplexity extensions apply to perplexity/ models. Respan cache controls and `customer_identifier` may be sent at the request root or under `respan_params`; nested values win when both are present.",
          "additionalProperties": true,
          "properties": {
            "model": {
              "type": "string",
              "description": "OpenAI: use a supported model such as gpt-6-luna. Azure: use azure/<your-deployment-name>. Perplexity: use a provider-prefixed model, such as perplexity/sonar. Bedrock: use a bedrock-prefixed inference profile, such as bedrock/us.openai.gpt-6.1-sol."
            },
            "input": {
              "description": "Text or structured input for the response.",
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "array",
                  "items": {}
                }
              ]
            },
            "stream": {
              "type": "boolean",
              "default": false,
              "description": "Return Responses API server-sent events when true."
            },
            "preset": {
              "type": "string",
              "description": "Perplexity Agent API preset, such as `medium`. Send it with `model`: a preset alone fails Respan's model validation."
            },
            "max_steps": {
              "type": "integer",
              "minimum": 1,
              "description": "Maximum Perplexity agent steps."
            },
            "language_preference": {
              "type": "string",
              "description": "Preferred response language for Perplexity Agent API."
            },
            "response_format": {
              "type": "object",
              "description": "Perplexity Agent API structured response configuration."
            },
            "skills": {
              "type": "array",
              "description": "Perplexity Agent API skills.",
              "items": {}
            },
            "tools": {
              "type": "array",
              "description": "Response tools. Perplexity supports web_search with filters such as search_domain_filter.",
              "items": {}
            },
            "respan_params": {
              "type": "object",
              "description": "Respan metadata, prompt configuration, customer identifiers, provider credentials, and other gateway parameters.",
              "properties": {
                "credential_override": {
                  "type": "object",
                  "description": "Request-scoped provider credentials. Named examples prefill the correct selector; keep that selector and replace only its credential values. OpenAI and Azure selectors exactly match model. Perplexity uses an empty-string selector because its credential is provider-scoped.",
                  "additionalProperties": {
                    "type": "object",
                    "additionalProperties": true,
                    "properties": {
                      "api_key": {
                        "type": "string",
                        "format": "password",
                        "writeOnly": true,
                        "description": "API key for the selected upstream provider, not your Respan API key. Enter the Respan key in the Authorization control."
                      },
                      "api_base": {
                        "type": "string",
                        "format": "uri",
                        "description": "Azure OpenAI resource endpoint, for example https://YOUR_RESOURCE.openai.azure.com."
                      },
                      "api_version": {
                        "type": "string",
                        "description": "Azure OpenAI API version. The Azure example prefills 2025-04-01-preview, which supports the Responses API."
                      }
                    }
                  }
                },
                "cache_enabled": {
                  "type": "boolean",
                  "description": "Enable response caching for this request."
                },
                "cache_ttl": {
                  "type": "number",
                  "description": "Cache lifetime in seconds. A response stored without `cache_ttl` is served from the cache for at most 30 minutes."
                },
                "cache_options": {
                  "type": "object",
                  "properties": {
                    "cache_by_customer": {
                      "type": "boolean"
                    },
                    "is_cached_by_model": {
                      "type": "boolean"
                    },
                    "omit_log": {
                      "type": "boolean"
                    }
                  },
                  "additionalProperties": false
                },
                "customer_identifier": {
                  "type": "string",
                  "description": "End-customer identifier used for logging and optional cache partitioning."
                }
              }
            },
            "cache_enabled": {
              "type": "boolean",
              "description": "Enable response caching for this request."
            },
            "cache_ttl": {
              "type": "number",
              "description": "Cache lifetime in seconds. A response stored without `cache_ttl` is served from the cache for at most 30 minutes."
            },
            "cache_options": {
              "type": "object",
              "properties": {
                "cache_by_customer": {
                  "type": "boolean"
                },
                "is_cached_by_model": {
                  "type": "boolean"
                },
                "omit_log": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            },
            "customer_identifier": {
              "type": "string",
              "description": "End-customer identifier used for logging and optional cache partitioning."
            }
          },
          "required": [
            "input"
          ]
        }
      }
    }
  },
  "tags": [
    "Gateway"
  ],
  "security": [
    {
      "RespanApiKey": []
    }
  ],
  "responses": {
    "200": {
      "description": "Response object or event stream from the selected Responses upstream.",
      "headers": {
        "X-Respan-Log-Id": {
          "description": "Unique ID of the Respan request log.",
          "schema": {
            "type": "string"
          }
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "additionalProperties": true
          }
        }
      }
    },
    "400": {
      "description": "Invalid request, provider route configuration, or upstream provider request. Include `input` and a route-appropriate `model`.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "nullable": true
                  },
                  "code": {
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      }
    },
    "401": {
      "description": "No usable provider credential, or the provider rejected it. Configure the provider in Settings › Providers, or pass `respan_params.credential_override`.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "nullable": true
                  },
                  "code": {
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      }
    },
    "403": {
      "$ref": "#/components/responses/InvalidApiKey"
    },
    "422": {
      "description": "Request validation failed.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "nullable": true
                  },
                  "code": {
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
```

</details>
<!-- openapi-operation:end -->

<!-- openapi-path-item:start -->
<details class="api-schema-source">
<summary>OpenAPI path metadata</summary>


```json
{}
```

</details>
<!-- openapi-path-item:end -->

<!-- openapi-components:start -->
<details class="api-schema-source">
<summary>Referenced OpenAPI components</summary>


```json
{
  "responses": {
    "InvalidApiKey": {
      "description": "The API key is missing, invalid or expired.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "detail"
            ],
            "properties": {
              "detail": {
                "type": "string"
              }
            }
          },
          "example": {
            "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
          }
        }
      }
    }
  },
  "securitySchemes": {
    "RespanApiKey": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "Respan API key",
      "description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.",
      "x-fern-bearer": {
        "name": "respanApiKey",
        "env": "RESPAN_API_KEY"
      }
    }
  }
}
```

</details>
<!-- openapi-components:end -->
