Skip to Content
Launching the open-source gateway

Create a response

POSThttps://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 > 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

Authentication

RespanApiKey

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.

HTTP scheme: bearer; format: Respan API key.

HTTP
Authorization: Bearer $RESPAN_API_KEY

Headers

Parameter Type Required Description and constraints
X-Respan-Route-Provider string Optional
Responses upstream. Each named API Explorer example prepopulates its matching value; keep the header paired with the selected example. Perplexity and Bedrock routing is header-only, case-insensitive, and whitespace-tolerant.
Allowed: "openai", "azure", "perplexity", "bedrock"

Query parameters

Parameter Type Required Description and constraints
format string Optional
Allowed: "json", "txt"

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 are accepted only when X-Respan-Route-Provider is perplexity. Respan cache controls and customer_identifier may be sent at the request root or under respan_params; nested values win when both are present.
Additional properties are allowed
model string Optional
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, or send models instead. Bedrock: use a bedrock-prefixed inference profile, such as bedrock/us.openai.gpt-6.1-sol.
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
-
stream boolean Optional
Return Responses API server-sent events when true.
Default: false
preset string Optional
Perplexity Agent API preset, such as medium. Send it with model or models: a preset alone fails Respan’s model validation.
models array<string> Optional
Perplexity Agent API fallback model chain, tried in order.
models[] string Array item
-
max_steps integer Optional
Maximum Perplexity agent steps.
Minimum: 1
language_preference string Optional
Preferred response language for Perplexity Agent API.
response_format object Optional
Perplexity Agent API structured response configuration.
skills array<any> Optional
Perplexity Agent API skills.
skills[] any Array item
-
tools array<any> Optional
Response tools. Perplexity supports web_search with filters such as search_domain_filter.
tools[] any Array item
-
respan_params object Optional
Respan metadata, prompt configuration, customer identifiers, provider credentials, and other gateway parameters. route_provider_override here cannot activate the Perplexity route.
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.
Format: password
Write only
respan_params.credential_override.<key>.api_base string Optional
Azure OpenAI resource endpoint, for example https://YOUR_RESOURCE.openai.azure.com .
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.
cache_enabled boolean Optional
Enable response caching for this request.
cache_ttl number Optional
Cache lifetime in seconds. A response stored without cache_ttl is served from the cache for at most 30 minutes.
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
-
customer_identifier string Optional
End-customer identifier used for logging and optional cache partitioning.

OpenAPI request schema

{
  "type": "object",
  "description": "OpenAI Responses API request. Standard Responses fields are accepted. Perplexity extensions are accepted only when X-Respan-Route-Provider is perplexity. 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, or send `models` instead. 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` or `models`: a preset alone fails Respan's model validation."
    },
    "models": {
      "type": "array",
      "description": "Perplexity Agent API fallback model chain, tried in order.",
      "items": {
        "type": "string"
      }
    },
    "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. route_provider_override here cannot activate the Perplexity route.",
      "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"
  ]
}

Examples

openai

Headers

JSON
{ "X-Respan-Route-Provider": "openai", "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

Terminal
curl --request POST 'https://api.respan.ai/api/responses' \ --header "Authorization: Bearer $RESPAN_API_KEY" \ --header 'X-Respan-Route-Provider: openai' \ --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

Python

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", "X-Respan-Route-Provider": "openai", }, method="POST", ) with urllib.request.urlopen(request) as response: print(json.load(response))

TypeScript

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", "X-Respan-Route-Provider": "openai", }, 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());

Python SDK (respan-api)

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( respan_route_provider="openai", **payload, ) print(response)

TypeScript SDK (@respan/respan-api)

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({ "X-Respan-Route-Provider": "openai", "model": "gpt-6-luna", "input": "Reply with exactly ok.", "max_output_tokens": 32, "reasoning": { "effort": "none" }, "stream": false }); console.log(response);

azure

Headers

JSON
{ "X-Respan-Route-Provider": "azure", "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

Terminal
curl --request POST 'https://api.respan.ai/api/responses' \ --header "Authorization: Bearer $RESPAN_API_KEY" \ --header 'X-Respan-Route-Provider: azure' \ --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

Python

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", "X-Respan-Route-Provider": "azure", }, method="POST", ) with urllib.request.urlopen(request) as response: print(json.load(response))

TypeScript

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", "X-Respan-Route-Provider": "azure", }, 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());

Python SDK (respan-api)

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( respan_route_provider="azure", **payload, ) print(response)

TypeScript SDK (@respan/respan-api)

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({ "X-Respan-Route-Provider": "azure", "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);

perplexity

Headers

JSON
{ "X-Respan-Route-Provider": "perplexity", "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

Terminal
curl --request POST 'https://api.respan.ai/api/responses' \ --header "Authorization: Bearer $RESPAN_API_KEY" \ --header 'X-Respan-Route-Provider: perplexity' \ --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

Python

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", "X-Respan-Route-Provider": "perplexity", }, method="POST", ) with urllib.request.urlopen(request) as response: print(json.load(response))

TypeScript

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", "X-Respan-Route-Provider": "perplexity", }, 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());

Python SDK (respan-api)

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( respan_route_provider="perplexity", **payload, ) print(response)

TypeScript SDK (@respan/respan-api)

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({ "X-Respan-Route-Provider": "perplexity", "model": "perplexity/sonar", "input": "Reply with exactly ok.", "max_steps": 1, "max_output_tokens": 32, "stream": false }); console.log(response);

bedrock

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

Headers

JSON
{ "X-Respan-Route-Provider": "bedrock", "Authorization": "Bearer YOUR_RESPAN_API_KEY" }

Request

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

cURL

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

Python

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", "X-Respan-Route-Provider": "bedrock", }, method="POST", ) with urllib.request.urlopen(request) as response: print(json.load(response))

TypeScript

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", "X-Respan-Route-Provider": "bedrock", }, 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());

Python SDK (respan-api)

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( respan_route_provider="bedrock", **payload, ) print(response)

TypeScript SDK (@respan/respan-api)

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({ "X-Respan-Route-Provider": "bedrock", "model": "bedrock/us.openai.gpt-6.1-sol", "input": "Hello" }); console.log(response);

Responses

200

Response object or event stream from the selected Responses upstream.

Response headers

Parameter Type Required Description and constraints
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

OpenAPI response schema

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

400

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

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
-

OpenAPI response 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

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
-

OpenAPI response 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

The API key is missing, invalid or expired.

application/json

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

OpenAPI response schema

{
  "type": "object",
  "required": [
    "detail"
  ],
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
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
-

OpenAPI response 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
        }
      }
    }
  }
}

OpenAPI source

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

OpenAPI operation

{
  "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": {
        "X-Respan-Route-Provider": "openai",
        "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": {
        "X-Respan-Route-Provider": "azure",
        "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": {
        "X-Respan-Route-Provider": "perplexity",
        "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": {
        "X-Respan-Route-Provider": "bedrock",
        "Authorization": "Bearer YOUR_RESPAN_API_KEY"
      },
      "request": {
        "model": "bedrock/us.openai.gpt-6.1-sol",
        "input": "Hello"
      }
    }
  ],
  "parameters": [
    {
      "in": "header",
      "name": "X-Respan-Route-Provider",
      "required": false,
      "description": "Responses upstream. Each named API Explorer example prepopulates its matching value; keep the header paired with the selected example. Perplexity and Bedrock routing is header-only, case-insensitive, and whitespace-tolerant.",
      "schema": {
        "type": "string",
        "enum": [
          "openai",
          "azure",
          "perplexity",
          "bedrock"
        ]
      }
    },
    {
      "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 are accepted only when X-Respan-Route-Provider is perplexity. 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, or send `models` instead. 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` or `models`: a preset alone fails Respan's model validation."
            },
            "models": {
              "type": "array",
              "description": "Perplexity Agent API fallback model chain, tried in order.",
              "items": {
                "type": "string"
              }
            },
            "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. route_provider_override here cannot activate the Perplexity route.",
              "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`, or `models` for Perplexity.",
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

OpenAPI path metadata

{}

Referenced OpenAPI components

{
  "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"
      }
    }
  }
}