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.
Hosted Functions and their fallback calls run on Seldon workspace credits. Use a Seldon API key whose gateway policy permits managed serving; transient BYOK headers and customer-only policies cannot invoke the alias.
When reference BYOK is enabled for your workspace, you can separately select an eligible stored provider connection while preparing a Function. That connection funds only original/reference answers during development and explicit original Try or Compare. It does not fund the optimizer, judge, candidate evaluation or hosted calls. Review the separate reference estimate cap and managed spending cap before paid work.
Long inputs
If an input exceeds 256 KiB, or the work cannot finish within the 55-second call deadline, split or reduce it in your application rather than sending it as one call.
A valid long input may be handled by a pipeline that chunks it internally. A chunked pipeline is not available to activate until it has been measured on an input long enough to split; see Compare and activate.
If your application does the splitting, it also owns the chunk size and overlap, translating offsets back into the original input in the contract's declared unit, deduplication and merging, and the policy for repeated or conflicting results across chunks. An entity or quotation that crosses the overlap can still be missed, so test that case.
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.