Skip to main content
POST
/
v1
/
agent
Create Agent Response
curl --request POST \
  --url https://api.perplexity.ai/v1/agent \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "input": "<string>"
}
'
import requests

url = "https://api.perplexity.ai/v1/agent"

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

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

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({input: '<string>'})
};

fetch('https://api.perplexity.ai/v1/agent', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.perplexity.ai/v1/agent",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'input' => '<string>'
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

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

func main() {

	url := "https://api.perplexity.ai/v1/agent"

	payload := strings.NewReader("{\n  \"input\": \"<string>\"\n}")

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

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

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

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

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.perplexity.ai/v1/agent")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": \"<string>\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.perplexity.ai/v1/agent")

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

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

response = http.request(request)
puts response.read_body
{
  "created_at": 123,
  "id": "<string>",
  "model": "<string>",
  "object": "response",
  "output": [
    {
      "content": [
        {
          "text": "<string>",
          "type": "output_text",
          "annotations": [
            {
              "end_index": 123,
              "start_index": 123,
              "title": "<string>",
              "type": "<string>",
              "url": "<string>"
            }
          ]
        }
      ],
      "id": "<string>",
      "role": "assistant",
      "type": "message"
    }
  ],
  "error": {
    "message": "<string>",
    "code": "<string>",
    "type": "<string>"
  },
  "usage": {
    "input_tokens": 123,
    "output_tokens": 123,
    "total_tokens": 123,
    "cost": {
      "currency": "USD",
      "input_cost": 123,
      "output_cost": 123,
      "total_cost": 123,
      "cache_creation_cost": 123,
      "cache_read_cost": 123,
      "tool_calls_cost": 123
    },
    "input_tokens_details": {
      "cache_creation_input_tokens": 123,
      "cache_read_input_tokens": 123
    },
    "tool_calls_details": {}
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
input
required

Input content - either a string or array of input items

instructions
string

System instructions for the model

language_preference
string

ISO 639-1 language code for response language

max_output_tokens
integer<int32>

Maximum tokens to generate

Required range: x >= 1
max_steps
integer<int32>

Maximum number of research loop steps. If provided, overrides the preset's max_steps value. Must be >= 1 if specified. Maximum allowed is 10.

Required range: 1 <= x <= 10
model
string

Model ID in provider/model format (e.g., "openai/gpt-5", "anthropic/claude-sonnet-4-6"). If models is also provided, models takes precedence. Required if neither models nor preset is provided.

models
string[]

Model fallback chain. Each model is in provider/model format. Models are tried in order until one succeeds. Max 5 models allowed. If set, takes precedence over single model field. The response.model will reflect the model that actually succeeded.

Required array length: 1 - 5 elements
preset
string

Preset configuration name (e.g., "fast", "low", "medium", "high", "xhigh"). Pre-configured model with system prompt and search parameters. Required if model is not provided.

reasoning
ReasoningConfig · object
response_format
ResponseFormat · object

Specifies the desired output format for the model response

store
boolean

OpenAI-compatible storage toggle. Accepted for request compatibility; the echoed response always reports store: true.

stream
boolean

If true, returns SSE stream instead of JSON

tools
(WebSearchTool · object | FinanceSearchTool · object | PeopleSearchTool · object | FetchUrlTool · object | FunctionTool · object | SandboxTool · object | McpTool · object)[]

Tools available to the model

Web search tool configuration for the Responses API

Response

Successful response. Content type depends on stream parameter:

  • stream: false (default): application/json with Response
  • stream: true: text/event-stream with SSE events

Non-streaming response returned when stream is false

created_at
integer<int64>
required

Unix timestamp when the response was created

id
string
required

Unique identifier for the response

model
string
required

Model used for generation

object
enum<string>
required

Object type identifier

Available options:
response
output
(MessageOutputItem · object | SearchResultsOutputItem · object | FetchUrlResultsOutputItem · object | FinanceResultsOutputItem · object | PeopleSearchResultsOutputItem · object | FunctionCallOutputItem · object | SandboxResultsOutputItem · object | McpListToolsOutputItem · object | McpCallOutputItem · object)[]
required

Array of output items (messages, search results, tool calls)

status
enum<string>
required

Status of the response

Available options:
completed,
failed,
in_progress,
requires_action
error
ErrorInfo · object

Error details if the response failed

usage
ResponsesUsage · object

Token usage and cost information