Create Agent Response - Perplexity
Summary
The provided content outlines the API specification for creating an agent response via Perplexity AI's `v1/agent` endpoint. It details the `cURL` and `POST` request methods, including the required `Authorization` header with a Bearer token and a `Content-Type: application/json` header. The request body accepts an `input` field, which can be a string or an array of input items, along with optional parameters such as `instructions`, `language_preference`, `max_output_tokens`, `max_steps` (ranging from 1 to 10), `model` (e.g., "xai/grok-4-1"), `models` (a fallback chain of 1-5 models), `preset` ("fast-search", "pro-search"), `reasoning` effort, `response_format` (supporting `json_schema`), `stream` for SSE, and `tools` like `web_search` or `function_tool`. The response structure includes `created_at` (Unix timestamp), `id`, `model` used, `object` type ("response"), an `output` array containing messages and tool results, `status`, `error` details, and `usage` information covering input/output tokens and costs in USD.
Key takeaway
For AI Architects designing conversational agents or data pipelines, understanding Perplexity AI's `v1/agent` API is crucial. You should leverage the `models` fallback chain for robust model selection and utilize `response_format.json_schema` to ensure structured, validated outputs. This allows for predictable integration into downstream systems and better control over response generation, especially when dealing with varied input types or requiring specific data formats.
Key insights
Perplexity AI's agent API enables structured, customizable AI responses with detailed control over models and tools.
Principles
- API requests require Bearer token authorization.
- Model selection supports fallback chains and presets.
- Output can be structured via JSON schema.
Method
To create an agent response, send a POST request to `/v1/agent` with an input payload, specifying model, instructions, and optional tools. The API returns a JSON object with output content, status, and usage metrics.
In practice
- Use `models` array for model fallback.
- Set `response_format.type` to `json_schema` for structured output.
- Monitor `usage.cost` for API expenditure.
Topics
- Perplexity AI Agent API
- Agent Response Creation
- API Request Parameters
- Model Selection
- Tool Integration
Best for: AI Architect, AI Product Manager, Entrepreneur, AI Engineer, Software Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by perplexity.ai via Google News.