# Create Agent Response

**POST** `/v1/agent`

Generate a response for the provided input with optional web search and reasoning.

Base URL: `https://api.perplexity.ai`

## Authorization

| Option | Scheme | Type | Sent as | Scopes |
| --- | --- | --- | --- | --- |
| Option 1 | `HTTPBearer` | `http` | `Authorization: Bearer <token>` | — |

## Request body

Required. Media type: `application/json`

### Example request body

```json
{
  "background": true,
  "input": "string",
  "instructions": "string",
  "language_preference": "string",
  "max_output_tokens": 0,
  "max_steps": 0,
  "model": "string",
  "models": [
    "string"
  ],
  "preset": "string",
  "previous_response_id": "string",
  "profile": {
    "id": "string",
    "type": "custom",
    "version": "string"
  },
  "reasoning": {
    "effort": "high"
  },
  "response_format": {
    "json_schema": {
      "description": "string",
      "name": "string",
      "schema": {
        "additionalProp1": null
      },
      "strict": true
    },
    "type": "json_schema"
  },
  "skills": [
    {
      "name": "office",
      "type": "builtin"
    }
  ],
  "store": true,
  "stream": true,
  "temperature": 0,
  "tools": [
    {
      "allowed_tools": [
        "string"
      ],
      "id": "string",
      "server_description": "string",
      "server_label": "string",
      "type": "connector"
    }
  ],
  "top_p": 0
}
```

## Responses

| Status | Description | Media type |
| --- | --- | --- |
| `200` | Successful response. Content type depends on `stream` parameter: - `stream: false` (default): `application/json` with Response - `stream: true`: `text/event-stream` with SSE events | `application/json, text/event-stream` |
| `400` | Invalid request. Includes an unresolvable `previous_response_id`: the referenced response does not exist, belongs to a different account, has failed, or is still running. | `application/json` |

### Example response: 200 — Successful response. Content type depends on `stream` parameter:
- `stream: false` (default): `application/json` with Response
- `stream: true`: `text/event-stream` with SSE events

```json
{
  "created_at": 0,
  "error": {
    "code": "string",
    "message": "string",
    "type": "string"
  },
  "id": "string",
  "model": "string",
  "object": "response",
  "output": [
    {
      "contents": [
        {
          "snippet": "string",
          "title": "string",
          "url": "string"
        }
      ],
      "type": "fetch_url_results"
    }
  ],
  "status": "cancelled",
  "usage": {
    "cost": {
      "cache_creation_cost": 0,
      "cache_read_cost": 0,
      "currency": "USD",
      "input_cost": 0,
      "output_cost": 0,
      "tool_calls_cost": 0,
      "total_cost": 0
    },
    "input_tokens": 0,
    "input_tokens_details": {
      "cache_creation_input_tokens": 0,
      "cache_read_input_tokens": 0
    },
    "output_tokens": 0,
    "tool_calls_details": {
      "additionalProp1": {
        "invocation": 0
      }
    },
    "total_tokens": 0
  }
}
```

### Example response: 400 — Invalid request. Includes an unresolvable `previous_response_id`: the referenced response does not exist, belongs to a different account, has failed, or is still running.

```json
{
  "error": {
    "code": "string",
    "message": "string",
    "type": "string"
  }
}
```

## Related pages

- [Add a skill revision](./updateskill.md)
- [Cancel Agent Response](./cancelagentresponse.md)
- [Create a skill](./createskill.md)
- [Create Async Chat Completion](./create_async_chat_completions_async_chat_completions_post.md)
- [Create Chat Completion](./chat_completions_chat_completions_post.md)
- [Create Contextualized Embeddings](./contextualized_embeddings_v1_contextualizedembeddings_post.md)
- [Create Embeddings](./embeddings_v1_embeddings_post.md)
- [Delete a skill](./deleteskill.md)
- [Download Agent Response File](./downloadagentfile.md)
- [Get a skill](./getskill.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
