Send a chat completion
Call a verified inference endpoint using cURL, handle a real completion response, and choose how to include shared context.
POST /v2/organizations/{organization_id}/endpoints/{endpoint_id}/chat/completions on the endpoint’s inference origin.
Send one request
Section titled “Send one request”- Open Inference → your endpoint → Connect. Copy the full HTTPS inference URL and the model ID. Set
SMOL_INFERENCE_URLandSMOL_MODEL_IDto those values on your backend. For an Application, first grant it access to this endpoint. - Obtain an access token. Create one request key before sending, and retain it with the intent in your application. For a single new interactive request,
export SMOL_REQUEST_KEY="$(python3 -c 'import uuid; print(uuid.uuid4())')". Do not generate another key to recover an existing request. - Run the following in the same trusted shell. This sends one generation and may incur provider charges. The shell example uses Python only to safely encode the JSON. Avoid shell tracing and running it on a shared machine where other users can inspect process arguments.
python3 -c 'import json,os,sys; json.dump({"model":os.environ["SMOL_MODEL_ID"],"messages":[{"role":"user","content":"Name one benefit of a shared glossary."}],"max_tokens":128,"stream":False},sys.stdout)' | curl --silent --show-error --fail-with-body --proto '=https' --max-time 90 \ --header "Authorization: Bearer $SMOL_ACCESS_TOKEN" \ --header "Idempotency-Key: $SMOL_REQUEST_KEY" \ --header 'Content-Type: application/json' \ --data-binary @- "$SMOL_INFERENCE_URL"On success, read choices[0].message.content. The following is an excerpt, not a required exact answer:
{ "object": "chat.completion", "choices": [{ "index": 0, "message": {"role": "assistant", "content": "A shared glossary keeps terminology consistent."}, "finish_reason": "stop" }]}Retain the X-Smol-Request-Id response header if present; it is not the completion body’s id. The backend examples capture it. Inspect it in the endpoint’s Activity or use the status API. A completed response with finish_reason: "length" may contain an incomplete answer. Usage, when reported, describes tokens; it is not a cash-savings estimate.
Request fields
Section titled “Request fields”| Field | Contract |
|---|---|
model |
Required. Use the exact model ID for this endpoint. |
messages |
Required. 1–32 messages with role and non-empty string content. System messages come first; include at least one user or assistant message. Send any conversation history you want the model to see. |
max_tokens |
Required positive integer. The protocol ceiling is 131,072; the model and endpoint may set a lower ceiling. |
stream |
Optional Boolean. Defaults to false. Set to true for SSE. |
temperature, top_p |
Optional numeric sampling controls. Protocol ranges are 0–2 and greater than 0 through 1, respectively. Use only settings supported by the model. |
smol_context |
Optional. A space UUID (lineage_id) and 1–128 distinct canonical handles from that one space. |
smol_context_mode |
Set to "none" to skip automatic context for this call. Do not combine it with an explicit selection. |
Text chat uses the fields above. Do not add arbitrary fields for tools, files or image inputs to this request. Submit JSON, without query parameters, with exactly one Idempotency-Key containing 1–128 visible ASCII characters (no spaces).
Choose how context is included
Section titled “Choose how context is included”- Use the endpoint defaults: omit both context fields. Attaching a space grants access; it does not by itself add every item to a request.
- Supply a particular version: add
smol_context, with the space ID and actual handles from that space. This replaces all automatic context for this request; it does not append to the defaults. - Skip automatic context: add
"smol_context_mode": "none"and omitsmol_context. This changes only this call.
For an explicit selection in a Python request body:
body["smol_context"] = { "lineage_id": os.environ["SMOL_LINEAGE_ID"], "handles": [os.environ["SMOL_CONTEXT_HANDLE"]],}An endpoint is not conversation memory. Sending several requests with one credential does not automatically add previous prompts or responses to a Context Space.