Skip to main content
Invoke a Profy Expert (AI Agent) and receive a complete response via SSE streaming, including text output, tool calls, and token usage.

Authentication

string
required
Bearer sk-pro-xxxx (API Key) or Bearer <access_token> (OAuth)
string
Required on API-key calls. A stable terminal-user id that isolates sessions, files, and memory. Omitting it returns 400, starting with Missing required header: X-Profy-End-User-Id. OAuth calls do not send it. Billing still charges the key owner.

Request Body

Persona, subagents, and delegation partners default to the Expert configured in Studio. profy-skills is not loaded on its own. This endpoint does not accept instructions.
string | object
required
Expert id. The shortest form is a string. The object form uses id for the same expert and may include versionId, model, and tools. versionId pins this run to one expert package version. Omit it to keep the version already bound to the session. tools adds to the expert’s platform tool list for this run. A tool the array does not name keeps its platform on or off state. A named extension, web_search, or web_fetch is on for this run, including when the platform switch is off. An empty array names nothing. Omitting the field also keeps the platform list. Every entry is {"type": ...}. A bare string is rejected. Allowed type values: request_user_input, imagegen, video, music, audio, generate_3d, postprocess_3d, generate_world, schedule, knowledge, obsidian_knowledge, memory, delegation, distill, web_search, web_fetch, mcp. mcp requires server_label and transport with type: "http" plus server_url. Optional headers is a string map, such as Authorization. That entry adds one HTTP server for this run and does not start connector login. The same server_label uses this request’s URL and headers. MCP the request does not name stays on the expert. read, bash, and skill stay either way. Plugins are environment.plugins, not this list. Top-level expert_identifier is an alias of agent.id and wins when both are set. The text model is the model field below. When rules is present it replaces this run’s identity, soul, agent, and guard. Omit it to keep the Studio text. An empty array clears those rules for this run. type is one of those four, and each type appears at most once. When subagents is present it replaces this run’s roster and turns spawning on. Omit it to keep the Expert roster, which still follows the key owner’s multi-task switch. Each agents entry needs name, description, system_prompt, and tools. model is optional. When expert_partner is present it replaces this run’s delegation roster. Omit it to keep the platform roster built from the whitelist and @-mentions. An empty array means this run delegates to nobody. Each entry requires identifier. Optional: name, brief (or description), needs_sandbox, mentioned. Listing an expert does not grant access; the delegate call still checks that you can use it.
string
required
Text model id for this run. Send it at the top level or as agent.model. When both are set, the value inside agent wins. Missing or blank returns Missing required field: model. Token precharge and settlement use this name and do not fall back to the Expert’s selected model. Image and video billing still follow the generation model, not this field.
object
Optional. profy_eval binds this turn to the creator’s offline experiment: experiment_id, task, and trial. The key owner must be that expert’s creator and the task must belong to the experiment, otherwise the call is 4xx and does not start. The object is removed before the prompt, attachments, and the in-flight fingerprint. Only the task verifier writes the score. Later turns of the same trial reuse one run row. Dataset upload and the summary are on Offline eval.
object
Optional. type is profy_hosted (platform sandbox), self_hosted (the caller’s desktop), or none (no shell). Omitted means profy_hosted. Any other value, including openai_hosted, returns 400. Each skills entry is {"type":"built_in","name":"docx"} or {"type":"customize","name":"..."}. profy-skills loads only when this array names it. A built_in entry loads that one skill from the pack. name: "*" loads the whole pack. Omit skills and this run has no product skill pack. customize reads a same-named skill from the key owner’s or the expert’s library on profy_hosted, and ~/.agents/skills/<name>/SKILL.md on self_hosted. Without this field, user, expert, and workspace skills still appear in discovery. An expert skill marked builtin pack or auto-evolution includes its full text. Other library skills include full text only when named here as customize, or through skill_names. Each plugins entry is {"type":"built_in","id":"sites"} and selects an installed plugin. capability_directories is only for self_hosted. Entries are local directories and must not contain ...
string | array
required
What to send the Expert. A string, or an array of { role, content } messages. Missing input returns Missing required field: input. message remains an alias.
boolean
Must be true or omitted. false returns 400. This endpoint is SSE only.
string
Session ID for multi-turn conversations. Not required for the first call — a new session_id is returned in the X-Session-Id response header.
string[]
File ids to attach, up to 20. Ids come from Upload File. The platform materializes each file in this session’s directory (/home/user/workspace/<expert_identifier>/<session_id>/), where the Expert can read / grep it.Ids only, never URLs: the platform will not fetch a link you hand it, so you never have to publish a readable link to a private document.
object[]
HITL resume. When non-empty, input may be omitted. session_id must be the turn that emitted request_user_input. Each entry requires tool_call_id, tool_name, and decision. Put an Ask answer in modified_parameters.result. Optional: result, original_parameters, rejection_reason, is_error. camelCase (toolCallId and the rest) is accepted.

Request Examples

To change the model or the extensions for this run only, put them on the same request:

Response Format

The response is an SSE (Server-Sent Events) stream with hierarchical dot-notation event names (aligned with the OpenAI Responses API). The X-Session-Id header is present as soon as the handshake succeeds, before the body finishes. Later reads and stops use that id. See Sessions. Closing this SSE connection does not stop the turn. The model keeps generating, and tool calls and billing continue. To stop, call POST /v1/sessions/{id}/interrupt. To keep reading tokens, use GET /v1/sessions/{id}/events?live=1 (SSE while a turn is generating, 204 when it has finished), or poll the JSON log without live. Posting the same body again resubscribes and does not start another turn. A different body while the turn is still running returns 409. /v1/chat/completions stays synchronous: disconnecting cancels that request, and the contract above does not apply to it.

SSE Event Types

Every data payload carries a monotonic event_id and a type that matches the event: line. Text and thinking rename the internal content field to delta. The full vocabulary is on SSE Events. Unmapped internal events keep their original type.

Lifecycle Events

Output Events

Tool Call Events

Usage Events

Streaming Examples

How long one MCP call waits

A remote MCP declared in a plugin’s .mcp.json waits 300 seconds for one tool call. To wait longer, set tool_timeout_sec (10–3600 seconds) on that server. This endpoint has no timeout field in the request body. See Plugins. When the time is up, that one tool fails and the conversation continues.

Billing

Billed by token usage (billing unit token_split). Credits are deducted from the account that owns the API Key, not from the end user named in X-Profy-End-User-Id — that header only scopes sessions and attributes usage; it is not a billing subject. Formula: ceil(input_tokens × input_rate ÷ 1e6) + ceil(output_tokens × output_rate ÷ 1e6) (input and output are rounded up separately, then summed). Per-model rates are operational data, so read the current values from the model selector or the model list endpoint; the algorithm is fixed and documented in Billing Formulas. Read actual consumption for a call from the usage.token event — that is the authoritative value. Do not estimate with your own tokenizer and treat the result as a bill.

Error Codes

Next Steps

Upload File

Give the Expert a document to read

Chat Completions

OpenAI-compatible chat completions endpoint

Python SDK

Complete Python SDK guide