https://api.higgsfield.ai/v1/agent and use the standard Authorization: Key {key_id}:{key_secret} header. Requests and responses are JSON.
The Python and TypeScript v2 SDKs wrap this surface as client.agents.sessions / client.agents.media. See the quickstart for installation and usage; the reference below is the raw HTTP contract.
Create a session
POST /v1/agent/sessions → 201
Send a message
POST /v1/agent/sessions/{session_id}/messages → 202
content is plain text, 1–20,000 characters. The turn runs asynchronously — poll for the result.
One turn runs per session at a time. A message sent while a turn is in flight returns 409 session_busy; the losing request is not charged. Retry after the current turn finishes, or interrupt it.
Read messages
GET /v1/agent/sessions/{session_id}/messages → 200
Optional query parameter after={message_id} returns only messages created after that message — use it to poll incrementally.
- Top-level
statusis the session status:idle,processing, orawaiting_input. - Message
statusisprocessing,completed, orfailed. - A user message settles to
completedorfailedtogether with the assistant message that answers it. - The assistant
messageis structured; concatenate itspartsentries with"type": "text"for the answer text. Other part types (reasoning, tool activity) may appear and can be ignored.
Interrupt a turn
POST /v1/agent/sessions/{session_id}/interrupt → 202
Questions from the agent
When the agent needs a decision it parks the turn and the session status becomesawaiting_input. The parked assistant message contains the question. Answer with a regular POST …/messages — the reply resumes the same turn. Nothing times out on our side, but the session stays parked until you answer or interrupt.
Upload input files
Give the agent input files by uploading them first and referencing the returned URL in your message content.POST /v1/agent/media → 201
PUT the file bytes to upload_url with the returned Content-Type header, and confirm:
POST /v1/agent/media/{id}/confirm with { "type": "image" }.
The confirmation response contains status: "uploaded" when the file is ready, or status: "not_ready" when it is not yet available. The SDKs return the URL only after uploaded; otherwise they raise AgentError in Python or HiggsfieldError in TypeScript.
Use the url in your message: "content": "Animate this image: https://cdn.higgsfield.ai/agent-media/…". Supported types: image, video, audio, file.
Errors
A
failed assistant message means the turn itself errored; the message reserve is refunded automatically and the session returns to idle.
Billing
Two independent meters apply:- Turn cost. Sending a message places a fixed credit reserve (the per-message ceiling). When the turn completes, the reserve is reconciled to the turn’s actual LLM usage and the difference is refunded automatically. Failed turns are refunded in full. The turn’s actual LLM cost appears on the user message as
llm_cost_usd(US dollars; converted to credits at your account’s rate for the refund). - Generations. Every model the agent runs is billed separately at that model’s listed price, identical to calling the model endpoint yourself. Failed generations are auto-refunded. The agent only uses models from the public catalog.