Skip to main content
All endpoints live under 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/sessions201
Sessions are durable and keep conversation memory across turns. Create one session per logical conversation or workflow and reuse it.

Send a message

POST /v1/agent/sessions/{session_id}/messages202
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}/messages200 Optional query parameter after={message_id} returns only messages created after that message — use it to poll incrementally.
  • Top-level status is the session status: idle, processing, or awaiting_input.
  • Message status is processing, completed, or failed.
  • A user message settles to completed or failed together with the assistant message that answers it.
  • The assistant message is structured; concatenate its parts entries with "type": "text" for the answer text. Other part types (reasoning, tool activity) may appear and can be ignored.
Poll with backoff: start at two seconds, increase gradually to ten, and stop when the assistant message for your turn is terminal. See Polling for the general strategy.

Interrupt a turn

POST /v1/agent/sessions/{session_id}/interrupt202
Asks the running turn to stop at the next safe point. The turn still settles normally (its assistant message reaches a terminal status), after which the session accepts new messages. Interrupting does not undo generations that already ran.

Questions from the agent

When the agent needs a decision it parks the turn and the session status becomes awaiting_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/media201
Then 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:
  1. 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).
  2. 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.
All charges and refunds appear in your account’s transaction history with the message or request id as the reference.