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. - SDK defaults
stream: false,n: 1,top_p: 1,frequency_penalty: 0andpresence_penalty: 0are accepted. Other values are rejected. max_completion_tokensnames the same logical output allowance asmax_tokens. It must match the saved allowance; if both names are present they must agree.- Unsupported options return
400 invalid_function_requestwith areasonandparam. Validation happens before an execution or spending reservation is created.
Structured output through an SDK
Import the request your SDK actually sends, including its output schema and generation settings. OpenAI Python parse, LangChain's json_schema mode and PydanticAI NativeOutput can then call the alias with that same contract.
For a single-call Function, you can also register one forced function tool as its output format. Supply one tools entry with object-valued JSON Schema parameters and tool_choice: "required" or a choice naming that tool. Omit parallel_tool_calls or set it to false. Keep those fields exactly as registered on subsequent calls. Do not combine tools with response_format.
For these Functions, the result is JSON in choices[0].message.tool_calls[0].function.arguments, with the registered name, content: null and finish_reason: "tool_calls". PydanticAI's tool-output parser can consume it. Seldon does not execute a tool or continue an agent loop. Multiple tools, automatic tool choice and parallel tool calls remain unsupported.
Existing JSON-content Functions keep their response format. Adopting tool output requires a new Function contract and the usual comparison and activation steps. The guarantee is the registered schema and wire format, not identical generated answers.
Your chosen provider must support the exact format. Bedrock Converse currently rejects explicit parallel_tool_calls: false; Seldon refuses this combination before sending a paid provider request. Do not change a saved contract just to bypass an incompatibility—prepare and compare the supported request first.
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 model, messages and the SDK defaults listed above. Tool-output Functions use the single-call messages format instead.
The response
The response is a standard chat completion:
choices[0].message.contentis JSON that matches the function's output schema, unless the registered output format is a forced tool as described above.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.
Templates and contract drift
For a template-mode Function, send the fully rendered original prompt. Matching extracts variable values and rejects changed fixed instructions, ambiguous matches, changed settings or schemas before execution. Errors identify a safe reason and param without reflecting your prompt. Use & monitor counts rejected requests separately from executed calls; earlier unmeasured days remain unknown.
For an input-object Function, a client-side fallback must reconstruct the original prompt and settings. Sending the bare Function input object to an ordinary model loses its instructions. Publish a candidate and rehearse its pinned alias through your real SDK and parser before changing production traffic.
Existing client setup
The Use panel provides setup fixtures for these clients. Keep the selected operation's existing instructions, messages, structured-output schema and parser; change its endpoint, API key and model route. Do not replace the application's global model configuration. The panel also displays the exact registered request.
These setup fixtures are executed by the Python/Node compatibility tests. Setup validation is separate from Function execution and semantic quality evaluation. Function aliases use Chat Completions; a Responses-default model is unsupported.