Responses API
Use the OpenAI-compatible Responses endpoint with OpenAI, Azure OpenAI, or Perplexity Agent API.
Send OpenAI Responses-shaped requests to:
Respan authenticates the request, routes it to the selected provider, and records the response, actual model, usage, latency, and cost.
Choose a route
The Perplexity route is header-only. Putting route_provider_override: perplexity in the body, respan_params, or a stored prompt does not activate it. The header value is case-insensitive and surrounding whitespace is ignored.
The Perplexity value applies only to POST /api/responses. It is ignored on Chat Completions and provider passthrough endpoints. Without the header, existing OpenAI routing is unchanged.
All routes require input. OpenAI and Azure OpenAI also require model. Perplexity may omit model only when it supplies preset or models.
OpenAI route
OpenAI is the default route. You may omit X-Respan-Route-Provider, or set it explicitly to openai.
The BYOK request below uses two keys:
RESPAN_API_KEYauthenticates the request to Respan.OPENAI_API_KEYauthenticates Respan to OpenAI for this request.
Respan keeps openai/gpt-5.1 as the canonical model for credential lookup and logging, then sends the bare model name to OpenAI. The credential_override key must match the model string in the request. You can omit respan_params after configuring OpenAI under Settings → Providers, or when managed OpenAI credentials are available through Respan credits.
Azure OpenAI route
Set X-Respan-Route-Provider: azure to route the request through Azure OpenAI. Use an azure/-prefixed deployment name in both model and credential_override so the credential lookup is unambiguous.
The BYOK request requires:
RESPAN_API_KEYfor Respan authentication.AZURE_OPENAI_API_KEYfor the Azure resource.AZURE_OPENAI_ENDPOINT, such ashttps://YOUR_RESOURCE.openai.azure.com.AZURE_OPENAI_API_VERSION, matching the deployment.
Replace gpt-4o with your Azure deployment name. Respan strips the azure/ prefix before calling the Azure SDK. You can omit respan_params after configuring an Azure OpenAI provider integration containing all three credential fields.
See Azure OpenAI provider setup.
Perplexity Agent API route
The default BYOK request uses two keys:
RESPAN_API_KEYauthenticates the request to Respan.PERPLEXITY_API_KEYis passed as a request-scoped provider credential.
You can omit the request-scoped credential after adding Perplexity under Settings → Providers, or when managed Perplexity credentials are available through Respan credits.
The empty-string selector inside credential_override is intentional. Perplexity Agent API credentials are provider-scoped rather than tied to a single model. Never commit a real provider key; load it from an environment variable or store it in Settings → Providers.
The response model is the actual model selected by Perplexity. A preset-only request therefore does not need a model field.
Perplexity request shapes
Explicit model
Perplexity Agent API accepts provider-prefixed model names. Respan passes the name through unchanged.
Preset-only
Omit model and let Perplexity select one using a preset.
Fallback chain
Use models to provide models in the order Perplexity should try them.
Streaming
Set stream: true to receive Responses API server-sent events. The stream ends with a response.completed event.
Perplexity parameters
These extensions are accepted only when the Perplexity route header is present:
Perplexity-only parameters are discarded on non-Perplexity routes.
Web search filters
Perplexity credentials
Per-request BYOK
Pass the Perplexity key under the provider-scoped empty-string selector:
The Respan API key still belongs in Authorization: Bearer YOUR_RESPAN_API_KEY; it is not replaced by the Perplexity key.
Stored or managed credentials
Alternatively, add a Perplexity provider integration with an api_key. The credential is provider-scoped: an older integration’s Sonar available_models list does not restrict Agent API model or preset requests. Managed Perplexity credentials can be used when available through Respan credits.
If neither a customer-owned nor a managed Perplexity credential is available, the endpoint returns 401 and asks you to add a Perplexity API key.
See Perplexity provider setup.
Logging and billing
Every successful route returns X-Respan-Log-Id.
Perplexity cost details
For Perplexity, Respan logs:
provider_id: perplexity- the actual model returned by Perplexity
- provider-reported USD cost when present
- input, output, cache-read, cache-creation, and tool-call cost components
Perplexity’s reported usage.cost.total_cost is authoritative for logging and credit deduction. If the component values do not reconcile with the total, Respan records the difference under provider_reported. Missing or invalid cost data falls back to catalog token-pricing estimates.
Troubleshooting
See Create response for the endpoint reference, or open the OpenAI, Azure OpenAI, and Perplexity provider setup guides.