Assistant API
Compare inference models and adapters before choosing a workflow. The session assistant contract below is distinct from provider-style completions; available model selections depend on the endpoint.
- Base URL
https://api.samsar.one/v1- Route prefix
/assistant · alias /api/v1/assistant- Authentication
- Bearer API key
- Execution
- Synchronous · OpenAI-compatible Responses payload
- Billing
- Published input, output, and cached-input token rates
- Content type
application/json
Use this API for assistant behavior tied to an existing Samsar session_id. It uses the account's selected assistant model and custom system prompt, or a minimal default prompt. Conversation history is reused across turns. OpenAI Responses-backed calls can also continue a previous response chain; Claude, Gemini, Kimi, and Qwen use their corresponding adapters and session messages.
Choose the contract that matches your integration:
| Contract | Session and response behavior |
|---|---|
/v1/assistant/completion | Existing Samsar session; synchronous Responses-compatible JSON. This route does not expose SSE. |
/v2/external/chat/completions and external assistant aliases | Caller-provided messages; JSON, named SSE events, or queued polling. |
Studio popup /assistants/* | Signed-in application session; queued replies, SSE snapshots, message deletion, and conversation reset. These are client routes, not aliases for the public API above. |
Billing and retries
See the final token prices for input, output, and cached-input credits per one million tokens. Choose the row matching your model, adapter, context, and date period. The listed prices also apply to public external chat/assistant endpoints and external-user assistants on those routes.
Production agent pipeline inference retains its flat stage pricing. Media, narrative, and utility endpoints have their own published rates; see Models & pricing.
Send an Idempotency-Key header when retrying a logical request. In samsar-js, use { idempotencyKey: 'stable-request-id' } in request options. A stable client_request_id is also accepted; when both identifiers are supplied, the client request ID takes precedence. Keys are scoped to the account and request scope, including the session and external identity for session assistants. Use a non-empty string of at most 512 characters.
- The same key and payload return the saved response with the original charge. A changed payload under the same key returns
409. - Replayed
x-credits-chargedvalues describe the original debit; they are not additional charges. Polling does not create another inference charge. - A request without a stable key is a new submission, even if its text matches an earlier request.
A positive credit balance and sufficient API-key allowance are required before a request starts. The final charge can exceed the available balance; further requests are blocked until credits are restored.
Requests awaiting billing confirmation or completion after a timeout can remain pending. Continue checking the existing request and retry with the same key to avoid a second submission.
Paid-tool limitations
The token tables cover model tokens only. Image generation, web/file search, hosted code execution, and other paid tools may incur separate charges. Requests using these tools can remain pending until billing is confirmed. Reuse the existing request key while checking completion.
POST /assistant/set_system_prompt
Store or clear the account-level system prompt used for assistant completions.
Request body
{
"system_prompt": "You are the launch assistant for Acme. Keep answers concise, on-brand, and commercially practical."
}
system_promptoptional string.- Pass
nullor an empty string to clear the custom prompt and revert to Samsar's default prompt.
Sample request
curl -X POST https://api.samsar.one/v1/assistant/set_system_prompt \
-H "Authorization: Bearer $SAMSAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"system_prompt": "You are the launch assistant for Acme. Keep answers concise, on-brand, and commercially practical."
}'
Success response (200)
{
"system_prompt": "You are the launch assistant for Acme. Keep answers concise, on-brand, and commercially practical.",
"model": "gpt-6.2-astra",
"selected_assistant_model": "gpt-6.2-astra"
}
Common errors
400invalid payload.401invalid API key.
POST /assistant/completion
Create a synchronous assistant response for an existing Samsar session. The request returns an OpenAI-compatible Responses payload so it can fit cleanly into modern OpenAI client flows.
You must provide a session_id. You can optionally send fresh user input in the same request. If you omit input, the assistant responds from the existing session history.
Request body
{
"session_id": "67df0d8ebc4f9d0b7f4fd123",
"input": [
{
"role": "user",
"content": [
{ "type": "input_text", "text": "Write a short product launch caption for this session." }
]
}
],
"max_output_tokens": 300
}
session_idrequired.inputoptional:- a string
- a single message object
- an array of message objects
- a multimodal content array such as
input_textandinput_image
max_output_tokens,temperature,top_p,reasoning,metadata,tools, andtool_choiceare accepted when supported by the configured assistant model.- On an OpenAI Responses-backed route that supports image tools, pass
tools: [{ "type": "image_generation" }]. To force an image response, settool_choiceto{ "type": "image_generation" }. Tools are not portable across all adapters. See Paid-tool limitations for separate charges and pending requests.
Multimodal example
{
"session_id": "67df0d8ebc4f9d0b7f4fd123",
"input": [
{
"role": "user",
"content": [
{ "type": "input_text", "text": "Describe the hero image and turn it into a headline." },
{ "type": "input_image", "image_url": "https://cdn.example.com/launch-hero.png" }
]
}
]
}
Image generation example
{
"session_id": "67df0d8ebc4f9d0b7f4fd123",
"input": "Create a clean launch-poster image for this session.",
"tools": [
{
"type": "image_generation",
"size": "1024x1024",
"quality": "high"
}
],
"tool_choice": {
"type": "image_generation"
}
}
Sample request
curl -X POST https://api.samsar.one/v1/assistant/completion \
-H "Authorization: Bearer $SAMSAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"session_id": "67df0d8ebc4f9d0b7f4fd123",
"input": [
{
"role": "user",
"content": [
{ "type": "input_text", "text": "Write a short product launch caption for this session." }
]
}
],
"max_output_tokens": 300
}'
Success response (200)
{
"id": "resp_123",
"object": "response",
"created_at": 1773651000,
"status": "completed",
"model": "gpt-6.2-astra",
"output_text": "Meet the new drop: sharp design, fast story, and a launch-ready look in one line.",
"output": [
{
"id": "resp_123_message",
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "Meet the new drop: sharp design, fast story, and a launch-ready look in one line.",
"annotations": []
}
]
}
],
"usage": {
"input_tokens": 482,
"output_tokens": 43,
"total_tokens": 525
}
}
Image response example
{
"id": "resp_456",
"object": "response",
"created_at": 1773651300,
"status": "completed",
"model": "gpt-6.2-astra",
"output": [
{
"id": "ig_456",
"type": "image_generation_call",
"status": "completed",
"revised_prompt": "A clean launch poster with a premium layout, strong product focal point, and minimal copy.",
"result": "iVBORw0KGgoAAAANSUhEUgAA..."
}
],
"usage": {
"input_tokens": 521,
"output_tokens": 22,
"total_tokens": 543
}
}
The result field contains a base64-encoded image. For follow-up image edits on the same supported OpenAI Responses route, keep using the same session_id so the response chain can be continued.
Headers
x-credits-chargedx-credits-remaining
Common errors
400missing or invalidsession_id, or invalidinput.401invalid API key.402insufficient credits.403session does not belong to the authenticated account.404session not found.409request already processing or the request key was reused with a different payload.502billing confirmation is pending; retry with the same request key.503provider outcome is unknown; inference is retained for reconciliation rather than repeated.
GPT and Claude model choices
Text inference, vision, and assistant requests support these models at high or xhigh effort:
| Samsar model | Native provider model | OpenRouter model |
|---|---|---|
gpt-6.2-astra | gpt-6.2-astra | openai/gpt-6.2-astra |
gpt-6.1-sol | gpt-6.1-sol | openai/gpt-6.1-sol |
claude-opus-5.5 | claude-opus-5-5 | anthropic/claude-opus-5.5 |
claude-fable-5.2 | claude-fable-5-2 | anthropic/claude-fable-5.2 |
Use OPENAI_API_KEY for native GPT, ANTHROPIC_API_KEY for native Claude, or OPENROUTER_API_KEY for OpenRouter. Samsar-hosted requests use SAMSAR_API_KEY. The default is Claude Fable 5.2 at high. Standalone installations use an available model when Fable is unavailable. Saved -xhigh model aliases remain accepted.
For pipeline and narrative calls, set inference_model and effort. For chat calls, set model and reasoning: { effort: "xhigh" } (or "high"). Account, Vidgenie, and Assistant selectors expose both model families and effort levels; standalone installations show only configured models.
Assistant token rates are listed on the pricing page. High and XHigh use the same per-token rates; total charges depend on actual input, cached input, and output usage. Thinking tokens count as output tokens. Gemini uses gemini-4-carbon with High thinking for inference and vision. Saved gemini-4-argon selections remain compatible and resolve to Carbon. Carbon assistant charges use the published input, cached-input, and output rates with a 20% markup; output includes thinking tokens, and Google regional rates and the December 1, 2026 pricing change apply.
Fable inference and vision use version 5.2 in High or XHigh. Saved Fable 5.1 selections upgrade to 5.2 with the same effort. Assistant billing applies a 20% markup to Fable 5.2 usage: base rates are $8/1M input, $0.20/1M cached input, and $40/1M output tokens (including thinking); 5-minute and 1-hour cache writes are $10/1M and $16/1M.
Astra inference, vision, and assistant requests use gpt-6.2-astra with high or xhigh effort. Saved gpt-6-astra choices upgrade with the same effort. Assistant billing adds 20% to the OpenAI base token rates: $9.60/1M input, $0.48/1M cached input, and $48/1M output tokens, including reasoning. Above 272K input tokens, the full request uses $19.20/1M input, $0.96/1M cached input, and $72/1M output.