wss://api.particle.ai/v1/responses using your existing Particle API key and a supported model. No extra access flag is needed. See Models for current model IDs.
Building with a coding agent? Give it the integration brief and protocol reference, or start with a runnable example below.
This is a WebSocket API, not
POST /v1/responses or Chat Completions with stream: true. Use a server-side WebSocket client. Keep your API key out of browser code; connect browsers through your own authenticated backend.The integration in three steps
- Connect with
Authorization: Bearer $PARTICLE_API_KEYand sendresponse.create. - Save
response.idfromresponse.created. When the user sends an update, sendresponse.steeron that same socket, targeting the saved ID. - Keep reading.
response.steer.acceptedacknowledges the update; a newresponse.createdwithprevious_response_idpointing to the original identifies the automatic continuation. We call that new response the successor.
type, previous_response_id, and input belong in a steer. Do not add model, stream_id, or generation settings. input can be a nonempty string or an array of user messages.
Try a complete example
Choose either example. Both use one conversation lane, send one update after the firstresponse.created, print streamed text, and wait for the successor to finish. Set PARTICLE_MODEL to your chosen model ID to override the example’s default.
The automatic trigger keeps this example simple. In your application, send the steer when a user submits new input while the response is active; you can also trigger it after a response.output_text.delta to see the direction change on screen.
Python
Use Python 3.11 or later:JavaScript (Node.js)
What to do with each event
Output already shown is not rewritten. Keep separate response records in your UI, with the user’s steering message between the original and successor. Only one steer can be pending per response; collect further edits locally until the successor is created.
Continue through client-owned tools
A steer does not cancel a tool, undo its effects, or turn partial function arguments into an executable call. Wait for complete call arguments and apply your usual validation and approval policy. If steering arrives after a function call has started streaming, Particle lets that response reach its tool boundary. It then sends an event like this:call_id on the same connection. Use the original’s stream_id if you assigned one. For structured results, JSON-encode the result into the output string.
input again. Unlike an automatic successor, this explicit create uses its own instructions, tools, reasoning settings, cache key, and token budget. Repeat whichever settings you want to keep. You can return the results after the original’s tool-call completion without waiting for response.steer.pending.
Hosted tools and approval-protocol events are not supported on this endpoint. Your application owns tool execution and approvals.
Failures, cancellation, and recovery
Forresponse.steer.failed, inspect error.code. Failures after acceptance carry the same steer.id; a rejection before acceptance may not have an ID.
To cancel, close the WebSocket. This cancels every active generation and hidden drain on that connection, including other lanes. There is no
response.cancel event. Use separate connections if tasks need independent cancellation.
Connection history is temporary. Before reconnecting, retain your input, completed output items, tool results, and steering submission state in your own application, consistent with your data policy. On a new socket:
- Do not reference an old
previous_response_id; omit it or set it tonull. - Send the history you want the model to see as
response.create.input. Emitted message, textual reasoning, and completed function-call items can be replayed. Preserve required tool-call/result pairs; do not invent a completed call from partial argument deltas. - Include a steering message only after deciding whether it was already incorporated into the history you are replaying. An accepted-but-pending update is not durably stored.
- Deduplicate external tool actions in your application. Retrying inference does not make a payment, file write, or other tool side effect idempotent.
Cost and cache behavior
Particle implements steering by replaying the accepted conversation into a new inference request, not by modifying a running model’s decode state. The successor inherits the original request settings and has its own token budget and usage. Keep stable instructions and tool definitions at the front of the conversation, and use oneprompt_cache_key per conversation. Automatic successors preserve it; explicit creates must repeat it. Routing remains cache-aware, not pinned to a worker. A successor can start before the original’s latest cache state is reusable, so a hit is not guaranteed. Read usage.input_tokens_details.cached_tokens on a terminal response with usage. See Prompt caching.