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

# Create a response

POST https://api.respan.ai/api/responses
Content-Type: application/json

Creates an OpenAI-compatible response through Respan. Choose the OpenAI, Azure, or Perplexity example and replace PROVIDER_API_KEY with that provider's key. For Azure, also replace YOUR_AZURE_DEPLOYMENT and YOUR_RESOURCE. Provider credentials can instead be stored in Settings > Providers. Successful responses include X-Respan-Log-Id and are logged with the provider model and cost.

Reference: https://www.respan.ai/docs/apis/gateway/create-response

## Authentication

- `Authorization` header (bearer token, required) — 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.

## Request

### Query parameters

- `format` (enum, optional)
  - Allowed values: `json`, `txt`

### Headers

- `X-Respan-Route-Provider` (enum, optional) — Responses upstream. Each named API Explorer example prepopulates its matching value; keep the header paired with the selected example. The Perplexity opt-in is header-only, case-insensitive, and whitespace-tolerant.
  - Allowed values: `openai`, `azure`, `perplexity`

### Body (application/json)

This endpoint expects an object.

- `input` (ApiResponsesPostRequestBodyContentApplicationJsonSchemaInput, required) — Text or structured input for the response.
- `model` (string, optional) — OpenAI: use a supported model such as gpt-4o-mini. Azure: use azure/\<your-deployment-name>. Perplexity: use a provider-prefixed model, such as perplexity/sonar, or send `models` instead.
- `stream` (boolean, optional, default: false) — Return Responses API server-sent events when true.
- `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` (list of string, optional) — Perplexity Agent API fallback model chain, tried in order.
- `max_steps` (integer, optional) — Maximum Perplexity agent steps.
- `language_preference` (string, optional) — Preferred response language for Perplexity Agent API.
- `response_format` (ApiResponsesPostRequestBodyContentApplicationJsonSchemaResponseFormat, optional) — Perplexity Agent API structured response configuration.
- `skills` (list of any, optional) — Perplexity Agent API skills.
- `tools` (list of any, optional) — Response tools. Perplexity supports web_search with filters such as search_domain_filter.
- `respan_params` (ApiResponsesPostRequestBodyContentApplicationJsonSchemaRespanParams, optional) — Respan metadata, prompt configuration, customer identifiers, provider credentials, and other gateway parameters. route_provider_override here cannot activate the Perplexity route.
- `cache_enabled` (boolean, optional) — Enable response caching for this request.
- `cache_ttl` (double, optional) — Cache lifetime in seconds. A response stored without `cache_ttl` is served from the cache for at most 30 minutes.
- `cache_options` (ApiResponsesPostRequestBodyContentApplicationJsonSchemaCacheOptions, optional)
- `customer_identifier` (string, optional) — End-customer identifier used for logging and optional cache partitioning.

## Response

### 200

Response object or event stream from the selected Responses upstream.

- `map from string to any`

## Errors

### 400 Bad Request Error

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

- `error` (ApiResponsesPostResponsesContentApplicationJsonSchemaError, required)

### 401 Unauthorized Error

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

- `error` (ApiResponsesPostResponsesContentApplicationJsonSchemaError, required)

### 403 Forbidden Error

The API key is missing, invalid or expired.

- `detail` (string, required)

### 422 Unprocessable Entity Error

Request validation failed.

- `error` (ApiResponsesPostResponsesContentApplicationJsonSchemaError, required)

## Types

### ApiResponsesPostRequestBodyContentApplicationJsonSchemaInput

Text or structured input for the response.

### ApiResponsesPostRequestBodyContentApplicationJsonSchemaResponseFormat

Perplexity Agent API structured response configuration.

### ApiResponsesPostRequestBodyContentApplicationJsonSchemaRespanParams

Respan metadata, prompt configuration, customer identifiers, provider credentials, and other gateway parameters. route_provider_override here cannot activate the Perplexity route.

- `credential_override` (map from string to ApiResponsesPostRequestBodyContentApplicationJsonSchemaRespanParamsCredentialOverride, 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.
- `cache_enabled` (boolean, optional) — Enable response caching for this request.
- `cache_ttl` (double, optional) — Cache lifetime in seconds. A response stored without `cache_ttl` is served from the cache for at most 30 minutes.
- `cache_options` (ApiResponsesPostRequestBodyContentApplicationJsonSchemaRespanParamsCacheOptions, optional)
- `customer_identifier` (string, optional) — End-customer identifier used for logging and optional cache partitioning.

### ApiResponsesPostRequestBodyContentApplicationJsonSchemaCacheOptions

- `cache_by_customer` (boolean, optional)
- `is_cached_by_model` (boolean, optional)
- `omit_log` (boolean, optional)

### ApiResponsesPostResponsesContentApplicationJsonSchemaError

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

### ApiResponsesPostRequestBodyContentApplicationJsonSchemaRespanParamsCredentialOverride

- `api_key` (string, optional) — API key for the selected upstream provider, not your Respan API key. Enter the Respan key in the Authorization control.
- `api_base` (string, optional) — Azure OpenAI resource endpoint, for example https://YOUR_RESOURCE.openai.azure.com.
- `api_version` (string, optional) — Azure OpenAI API version. The Azure example prefills 2025-04-01-preview, which supports the Responses API.

### ApiResponsesPostRequestBodyContentApplicationJsonSchemaRespanParamsCacheOptions

- `cache_by_customer` (boolean, optional)
- `is_cached_by_model` (boolean, optional)
- `omit_log` (boolean, optional)

## Examples

### openai

**Request**

```json
{
  "input": "Explain why small language models are useful.",
  "model": "gpt-4o-mini",
  "stream": false,
  "respan_params": {
    "credential_override": {
      "gpt-4o-mini": {
        "api_key": "PROVIDER_API_KEY"
      }
    }
  }
}
```

**Response**

```json
{
  "id": "resp_openai_example",
  "model": "gpt-4o-mini",
  "output": []
}
```

**SDK Code**

```python openai
import requests

url = "https://api.respan.ai/api/responses"

payload = {
    "input": "Explain why small language models are useful.",
    "model": "gpt-4o-mini",
    "stream": False,
    "respan_params": { "credential_override": { "gpt-4o-mini": { "api_key": "PROVIDER_API_KEY" } } }
}
headers = {
    "X-Respan-Route-Provider": "openai",
    "Authorization": "Bearer <respanApiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript openai
const url = 'https://api.respan.ai/api/responses';
const options = {
  method: 'POST',
  headers: {
    'X-Respan-Route-Provider': 'openai',
    Authorization: 'Bearer <respanApiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"input":"Explain why small language models are useful.","model":"gpt-4o-mini","stream":false,"respan_params":{"credential_override":{"gpt-4o-mini":{"api_key":"PROVIDER_API_KEY"}}}}'
};

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

```go openai
package main

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

func main() {

	url := "https://api.respan.ai/api/responses"

	payload := strings.NewReader("{\n  \"input\": \"Explain why small language models are useful.\",\n  \"model\": \"gpt-4o-mini\",\n  \"stream\": false,\n  \"respan_params\": {\n    \"credential_override\": {\n      \"gpt-4o-mini\": {\n        \"api_key\": \"PROVIDER_API_KEY\"\n      }\n    }\n  }\n}")

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

	req.Header.Add("X-Respan-Route-Provider", "openai")
	req.Header.Add("Authorization", "Bearer <respanApiKey>")
	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 openai
require 'uri'
require 'net/http'

url = URI("https://api.respan.ai/api/responses")

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

request = Net::HTTP::Post.new(url)
request["X-Respan-Route-Provider"] = 'openai'
request["Authorization"] = 'Bearer <respanApiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"input\": \"Explain why small language models are useful.\",\n  \"model\": \"gpt-4o-mini\",\n  \"stream\": false,\n  \"respan_params\": {\n    \"credential_override\": {\n      \"gpt-4o-mini\": {\n        \"api_key\": \"PROVIDER_API_KEY\"\n      }\n    }\n  }\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.respan.ai/api/responses")
  .header("X-Respan-Route-Provider", "openai")
  .header("Authorization", "Bearer <respanApiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": \"Explain why small language models are useful.\",\n  \"model\": \"gpt-4o-mini\",\n  \"stream\": false,\n  \"respan_params\": {\n    \"credential_override\": {\n      \"gpt-4o-mini\": {\n        \"api_key\": \"PROVIDER_API_KEY\"\n      }\n    }\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.respan.ai/api/responses', [
  'body' => '{
  "input": "Explain why small language models are useful.",
  "model": "gpt-4o-mini",
  "stream": false,
  "respan_params": {
    "credential_override": {
      "gpt-4o-mini": {
        "api_key": "PROVIDER_API_KEY"
      }
    }
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <respanApiKey>',
    'Content-Type' => 'application/json',
    'X-Respan-Route-Provider' => 'openai',
  ],
]);

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

```csharp openai
using RestSharp;

var client = new RestClient("https://api.respan.ai/api/responses");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Respan-Route-Provider", "openai");
request.AddHeader("Authorization", "Bearer <respanApiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": \"Explain why small language models are useful.\",\n  \"model\": \"gpt-4o-mini\",\n  \"stream\": false,\n  \"respan_params\": {\n    \"credential_override\": {\n      \"gpt-4o-mini\": {\n        \"api_key\": \"PROVIDER_API_KEY\"\n      }\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift openai
import Foundation

let headers = [
  "X-Respan-Route-Provider": "openai",
  "Authorization": "Bearer <respanApiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "input": "Explain why small language models are useful.",
  "model": "gpt-4o-mini",
  "stream": false,
  "respan_params": ["credential_override": ["gpt-4o-mini": ["api_key": "PROVIDER_API_KEY"]]]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/responses")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### azure

**Request**

```json
{
  "input": "Summarize the benefits of retrieval-augmented generation.",
  "model": "azure/YOUR_AZURE_DEPLOYMENT",
  "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
{
  "id": "resp_azure_example",
  "model": "azure/YOUR_AZURE_DEPLOYMENT",
  "output": []
}
```

**SDK Code**

```python azure
import requests

url = "https://api.respan.ai/api/responses"

payload = {
    "input": "Summarize the benefits of retrieval-augmented generation.",
    "model": "azure/YOUR_AZURE_DEPLOYMENT",
    "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"
            } } }
}
headers = {
    "X-Respan-Route-Provider": "azure",
    "Authorization": "Bearer <respanApiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript azure
const url = 'https://api.respan.ai/api/responses';
const options = {
  method: 'POST',
  headers: {
    'X-Respan-Route-Provider': 'azure',
    Authorization: 'Bearer <respanApiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"input":"Summarize the benefits of retrieval-augmented generation.","model":"azure/YOUR_AZURE_DEPLOYMENT","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"}}}}'
};

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

```go azure
package main

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

func main() {

	url := "https://api.respan.ai/api/responses"

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

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

	req.Header.Add("X-Respan-Route-Provider", "azure")
	req.Header.Add("Authorization", "Bearer <respanApiKey>")
	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 azure
require 'uri'
require 'net/http'

url = URI("https://api.respan.ai/api/responses")

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

request = Net::HTTP::Post.new(url)
request["X-Respan-Route-Provider"] = 'azure'
request["Authorization"] = 'Bearer <respanApiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"input\": \"Summarize the benefits of retrieval-augmented generation.\",\n  \"model\": \"azure/YOUR_AZURE_DEPLOYMENT\",\n  \"stream\": false,\n  \"respan_params\": {\n    \"credential_override\": {\n      \"azure/YOUR_AZURE_DEPLOYMENT\": {\n        \"api_key\": \"PROVIDER_API_KEY\",\n        \"api_base\": \"https://YOUR_RESOURCE.openai.azure.com\",\n        \"api_version\": \"2025-04-01-preview\"\n      }\n    }\n  }\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.respan.ai/api/responses")
  .header("X-Respan-Route-Provider", "azure")
  .header("Authorization", "Bearer <respanApiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": \"Summarize the benefits of retrieval-augmented generation.\",\n  \"model\": \"azure/YOUR_AZURE_DEPLOYMENT\",\n  \"stream\": false,\n  \"respan_params\": {\n    \"credential_override\": {\n      \"azure/YOUR_AZURE_DEPLOYMENT\": {\n        \"api_key\": \"PROVIDER_API_KEY\",\n        \"api_base\": \"https://YOUR_RESOURCE.openai.azure.com\",\n        \"api_version\": \"2025-04-01-preview\"\n      }\n    }\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.respan.ai/api/responses', [
  'body' => '{
  "input": "Summarize the benefits of retrieval-augmented generation.",
  "model": "azure/YOUR_AZURE_DEPLOYMENT",
  "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"
      }
    }
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <respanApiKey>',
    'Content-Type' => 'application/json',
    'X-Respan-Route-Provider' => 'azure',
  ],
]);

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

```csharp azure
using RestSharp;

var client = new RestClient("https://api.respan.ai/api/responses");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Respan-Route-Provider", "azure");
request.AddHeader("Authorization", "Bearer <respanApiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": \"Summarize the benefits of retrieval-augmented generation.\",\n  \"model\": \"azure/YOUR_AZURE_DEPLOYMENT\",\n  \"stream\": false,\n  \"respan_params\": {\n    \"credential_override\": {\n      \"azure/YOUR_AZURE_DEPLOYMENT\": {\n        \"api_key\": \"PROVIDER_API_KEY\",\n        \"api_base\": \"https://YOUR_RESOURCE.openai.azure.com\",\n        \"api_version\": \"2025-04-01-preview\"\n      }\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift azure
import Foundation

let headers = [
  "X-Respan-Route-Provider": "azure",
  "Authorization": "Bearer <respanApiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "input": "Summarize the benefits of retrieval-augmented generation.",
  "model": "azure/YOUR_AZURE_DEPLOYMENT",
  "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"
      ]]]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/responses")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### perplexity

**Request**

```json
{
  "input": "Summarize the latest developments in small language models.",
  "model": "perplexity/sonar",
  "stream": false,
  "max_steps": 1,
  "respan_params": {
    "credential_override": {
      "": {
        "api_key": "PROVIDER_API_KEY"
      }
    }
  }
}
```

**Response**

```json
{
  "id": "resp_perplexity_example",
  "model": "openai/gpt-5.1",
  "output": []
}
```

**SDK Code**

```python perplexity
import requests

url = "https://api.respan.ai/api/responses"

payload = {
    "input": "Summarize the latest developments in small language models.",
    "model": "perplexity/sonar",
    "stream": False,
    "max_steps": 1,
    "respan_params": { "credential_override": { "": { "api_key": "PROVIDER_API_KEY" } } }
}
headers = {
    "X-Respan-Route-Provider": "perplexity",
    "Authorization": "Bearer <respanApiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript perplexity
const url = 'https://api.respan.ai/api/responses';
const options = {
  method: 'POST',
  headers: {
    'X-Respan-Route-Provider': 'perplexity',
    Authorization: 'Bearer <respanApiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"input":"Summarize the latest developments in small language models.","model":"perplexity/sonar","stream":false,"max_steps":1,"respan_params":{"credential_override":{"":{"api_key":"PROVIDER_API_KEY"}}}}'
};

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

```go perplexity
package main

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

func main() {

	url := "https://api.respan.ai/api/responses"

	payload := strings.NewReader("{\n  \"input\": \"Summarize the latest developments in small language models.\",\n  \"model\": \"perplexity/sonar\",\n  \"stream\": false,\n  \"max_steps\": 1,\n  \"respan_params\": {\n    \"credential_override\": {\n      \"\": {\n        \"api_key\": \"PROVIDER_API_KEY\"\n      }\n    }\n  }\n}")

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

	req.Header.Add("X-Respan-Route-Provider", "perplexity")
	req.Header.Add("Authorization", "Bearer <respanApiKey>")
	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 perplexity
require 'uri'
require 'net/http'

url = URI("https://api.respan.ai/api/responses")

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

request = Net::HTTP::Post.new(url)
request["X-Respan-Route-Provider"] = 'perplexity'
request["Authorization"] = 'Bearer <respanApiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"input\": \"Summarize the latest developments in small language models.\",\n  \"model\": \"perplexity/sonar\",\n  \"stream\": false,\n  \"max_steps\": 1,\n  \"respan_params\": {\n    \"credential_override\": {\n      \"\": {\n        \"api_key\": \"PROVIDER_API_KEY\"\n      }\n    }\n  }\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.respan.ai/api/responses")
  .header("X-Respan-Route-Provider", "perplexity")
  .header("Authorization", "Bearer <respanApiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": \"Summarize the latest developments in small language models.\",\n  \"model\": \"perplexity/sonar\",\n  \"stream\": false,\n  \"max_steps\": 1,\n  \"respan_params\": {\n    \"credential_override\": {\n      \"\": {\n        \"api_key\": \"PROVIDER_API_KEY\"\n      }\n    }\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.respan.ai/api/responses', [
  'body' => '{
  "input": "Summarize the latest developments in small language models.",
  "model": "perplexity/sonar",
  "stream": false,
  "max_steps": 1,
  "respan_params": {
    "credential_override": {
      "": {
        "api_key": "PROVIDER_API_KEY"
      }
    }
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <respanApiKey>',
    'Content-Type' => 'application/json',
    'X-Respan-Route-Provider' => 'perplexity',
  ],
]);

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

```csharp perplexity
using RestSharp;

var client = new RestClient("https://api.respan.ai/api/responses");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Respan-Route-Provider", "perplexity");
request.AddHeader("Authorization", "Bearer <respanApiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": \"Summarize the latest developments in small language models.\",\n  \"model\": \"perplexity/sonar\",\n  \"stream\": false,\n  \"max_steps\": 1,\n  \"respan_params\": {\n    \"credential_override\": {\n      \"\": {\n        \"api_key\": \"PROVIDER_API_KEY\"\n      }\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift perplexity
import Foundation

let headers = [
  "X-Respan-Route-Provider": "perplexity",
  "Authorization": "Bearer <respanApiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "input": "Summarize the latest developments in small language models.",
  "model": "perplexity/sonar",
  "stream": false,
  "max_steps": 1,
  "respan_params": ["credential_override": ["": ["api_key": "PROVIDER_API_KEY"]]]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/responses")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```