Functions
Call a function from your app
Call an activated function through the gateway with your API key, pin revisions, send workflow inputs and retry safely.
An activated function is called through the same POST /v1/chat/completions endpoint, base URL and API key as any other model. There is no separate endpoint, and the base URL alone never selects a function: you call it by setting model to its alias.
Aliases and pinning
The function's Use section shows both, with JavaScript and Python snippets that read SELDON_API_KEY and SELDON_BASE_URL.
Single-call functions
Send the original messages unchanged, with your new input as the last user message:
response = client.chat.completions.create(
model="seldon/function/FUNCTION_ID",
messages=[
{"role": "system", "content": "SYSTEM_MESSAGE_FROM_THE_USE_SECTION"},
{"role": "user", "content": "Grace Ito leads design at Northwind."},
],
)
data = json.loads(response.choices[0].message.content)- Fixed messages must match the saved function exactly, in the same order and roles.
- You may omit
response_format,temperatureandmax_tokens. If you send them, they must equal the saved values. - Other options, including
streamandtools, are rejected.
Workflow functions
Send the input object as JSON in a single user message:
const response = await client.chat.completions.create({
model: "seldon/function/FUNCTION_ID",
messages: [
{
role: "user",
content: JSON.stringify({
mentions: [{ id: "m1", text: "Acme Labs" }],
catalog: [{ id: "acme", name: "Acme Research", aliases: ["Acme Labs"] }],
}),
},
],
});Seldon runs the internal steps and returns the final output. Workflow calls accept only model and messages.
The response
The response is a standard chat completion:
choices[0].message.contentis JSON that matches the function's output schema.usagesums tokens across every stage that ran, including any fallback.- A
seldonobject identifies what ran:
{
"seldon": {
"function_id": "FUNCTION_ID",
"revision_id": "REVISION_ID",
"fallback_used": false,
"execution_id": "EXECUTION_ID"
}
}fallback_used is true when the pipeline detected a failure and the original workflow produced the result. Fallback is not a check for silently wrong answers.
Limits and retries
- One call has a 55-second deadline and a small, fixed number of model calls.
- Requests are limited to 256 KiB.
- Workspaces can run 10 calls at once and start 5 per second. Excess calls return
429execution_capacity; retry with backoff and jitter. - Send an
Idempotency-Keyheader with a UUID to retry safely. A retry with the same key returns the stored result and keeps the original revision; while the first attempt is still running it returns409execution_in_progress. Reusing a key with different inputs returns409idempotency_conflict. - Optional spend and rate limits on the API key apply to function calls.
Functions run on workspace credits. BYOK credentials are not supported for function calls.
Fit it into your application
A function's measurements describe that function, not your whole agent. Evaluate the full application before you switch traffic. Streaming, open-ended conversation, tool execution and multimodal input remain outside Functions, even where ordinary routing supports them.
Seldon does not substitute functions for matching gateway requests automatically. A request reaches a function only when it uses the alias.
See Errors for function-specific codes.