Docs menu

Functions

Prepare a function

Start a function from an example, a plain-language task, an existing request, a short workflow or a call from your traces.

A function starts as a free draft. Open Functions and choose New function to see three tabs: Examples, Describe a task and Import. Saving a draft makes no model calls.

Before choosing a starting point, decide which input preparation, output policy and outcome scoring stays in your application. See Where the function sits.

Start from an example

Pick a starter on the Examples tab, edit it if you like, and choose Save draft. Starters use synthetic inputs; measured results appear only after a real run.

Describe a task

Write what the function should do under What should the function do? (up to 16 KiB) and choose a Reference model. The paid preview drafts a request and output schema for you to review. Results are compared against that reference implementation.

Import a single request

Paste an OpenAI chat request on the Import tab. Supported fields are model, messages, temperature, max_tokens and response_format.

JSON
{
  "model": "openai/gpt-5.4-nano",
  "messages": [
    { "role": "system", "content": "Extract every person, company and position. Return JSON." },
    { "role": "user", "content": "Ada Chen is an engineer at Acme." }
  ],
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "result",
      "schema": {
        "type": "object",
        "properties": { "jobs": { "type": "array", "items": { "type": "object" } } },
        "required": ["jobs"]
      }
    }
  }
}

Seldon treats the last user message as the variable input and every earlier message as fixed instructions. The draft records that assumption so you can confirm it in the preview.

Requirements:

  • At least one user message, and up to 32 messages.
  • Message content is plain text. Images, audio and other content parts are not supported.
  • Buffered SDK defaults such as stream: false are accepted. A single forced function tool can define structured output for a single-call Function; streaming and arbitrary tool execution remain unsupported. See the exact SDK contract.
  • The request is at most 256 KiB. Keep credentials out of it.

If you include a json_schema response format or a supported forced output tool, its schema becomes the output schema. Otherwise the preview drafts one.

Import a short workflow

A workflow is up to three calls whose inputs come from your input object or from earlier calls. Declare variable fields with {{name}} placeholders and map each one to a source with bindings:

JSON
{
  "inputs": {
    "mentions": [{ "id": "m1", "text": "Acme Labs" }],
    "catalog": [{ "id": "acme", "name": "Acme Research", "aliases": ["Acme Labs"] }]
  },
  "calls": [
    {
      "id": "link",
      "model": "openai/gpt-5.4-nano",
      "messages": [
        { "role": "system", "content": "Link each mention to an organization in the catalog." },
        { "role": "user", "content": "Mentions: {{mentions}}\nCatalog: {{catalog}}" }
      ]
    }
  ],
  "bindings": [
    { "call": "link", "message": 1, "placeholder": "{{mentions}}", "source": "input#/mentions" },
    { "call": "link", "message": 1, "placeholder": "{{catalog}}", "source": "input#/catalog" }
  ],
  "output_schema": {
    "type": "object",
    "properties": { "links": { "type": "array" } },
    "required": ["links"]
  }
}
  • source is input#/field for your input object, or callId#/field for an earlier call's output.
  • message is the zero-based index of the message that contains the placeholder.
  • Each placeholder appears exactly once in its message.
  • A placeholder whose name matches exactly one input field or earlier call is bound for you. Otherwise the preview asks you to choose a source.
  • output_schema must be a JSON Schema whose type is object or array. If you omit it, the last call's json_schema is used.

Workflow functions are called with the input object as JSON. See Call from your app.

Contract patterns

Grounded spans

For a function that identifies text in a source document, declare the entities and their exact positions in the output schema:

JSON
{
  "type": "object",
  "properties": {
    "entities": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "label": { "type": "string", "enum": ["PERSON", "EMAIL"] },
          "text": { "type": "string", "minLength": 1 },
          "start": { "type": "integer", "minimum": 0 },
          "end": { "type": "integer", "minimum": 1 }
        },
        "required": ["label", "text", "start", "end"],
        "additionalProperties": false
      }
    }
  },
  "required": ["entities"],
  "additionalProperties": false
}

In the fixed instructions, require text to copy the source exactly and declare the offset unit and whether end is exclusive. This example uses zero-based Unicode code-point offsets with an exclusive end; that unit is part of this contract, not a default to infer from the field names. If you choose another unit, change the instructions and application validation together.

Your application should check the bounds and that the source slice equals text in the declared unit, deduplicate or merge overlapping spans, and perform any redaction or pseudonymization itself. For an evidence field, require nonempty quotations copied exactly from the source so Seldon and your application can ground them.

Labeled classification

For a classifier, send signals your application has already prepared and return a closed set of decisions:

JSON
{
  "type": "object",
  "properties": {
    "risk_level": { "type": "string", "enum": ["low", "medium", "high"] }
  },
  "required": ["risk_level"],
  "additionalProperties": false
}

The variable input contains the prepared signals, such as amount, prior counts and whether a merchant was seen before. The outcome label is not an input field. Supply expected answers through Evaluation example imports, and keep a separate application held-out set for precision, recall, F1 or other outcome metrics.

Select a call from your traces

Under Or select a call from traces, upload an uncompressed .json or .jsonl export of up to 10 MiB in one of these formats:

  • LangSmith JSONL
  • Langfuse JSONL
  • Braintrust JSONL
  • OpenTelemetry OTLP JSON

Choose Upload and inspect calls. Each call is marked Ready to prepare, Needs clarification (for example, when the model or max_tokens was not recorded) or Unsupported. Choose Use this call to copy one call into a new draft. Uploads are free and expire after 24 hours; copied drafts remain.

Edit a draft

The draft editor lets you change messages and the model for each call, or switch to JSON. Editing a draft after a preview invalidates that preview. Use Edit draft and invalidate the current preview, then prepare a new preview.

Next steps

Prepare an existing operation

Keep the application's request construction and parser when adopting a Function. Import its actual model, messages, structured-output schema and settings. Omitted temperature and output-token limits stay omitted; a different explicit setting is a contract change.

To import a templated request, use kind: "template" with syntax: "python_format" or "jinja_variables", the original messages, example_inputs, and representative rendered samples. Python's doubled braces are literal braces. Formatting expressions, filters and adjacent variables are unsupported. Check and confirm the variables and every sample before saving. No model call is needed to check a template.

The optional Python CLI provides an alternative preparation entrance for an explicitly selected operation. It shares the dashboard's Function, run, examples and revision contracts. Its package and login availability are deployment prerequisites; importing from the dashboard remains available without it. Preparing a Function does not require replacing the application's SDK with the typed Seldon SDK.