Docs menu

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

Model valueBehavior
seldon/function/FUNCTION_IDFollows whichever revision you activate. Activating a new revision changes what this alias serves.
seldon/function/FUNCTION_ID@REVISION_IDPins one revision you have activated. Use it to roll forward deliberately.

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:

Python
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, temperature and max_tokens. If you send them, they must equal the saved values.
  • Other options, including stream and tools, are rejected.

Workflow functions

Send the input object as JSON in a single user message:

TypeScript
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.content is JSON that matches the function's output schema.
  • usage sums tokens across every stage that ran, including any fallback.
  • A seldon object identifies what ran:
JSON
{
  "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 429 execution_capacity; retry with backoff and jitter.
  • Send an Idempotency-Key header 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 returns 409 execution_in_progress. Reusing a key with different inputs returns 409 idempotency_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

Your applicationIntegration
One LLM callPoint that call at Seldon and change its model to the alias.
A short sequence of callsReplace the sequence with one workflow function call.
An agent with per-step model settingsSet only the suitable step to the alias and the Seldon base URL.
An agent with custom tools or adaptersWrap the function call in a tool or adapter.
One global model settingUse the alias only if every request shares the function's contract.

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.

Call a function from your app | Seldon