Concepts

Input types

An input is typed, and it can be text, a picture, a document, a recording, a clip or a set of passages. Each one can arrive as a value or a URL.

7 typescontent · url
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

The shape

{ type, content?, url?, mime? }
{"type": ..., "content": ..., "url": ..., "mime": ...}
typeCarries
texta string, in content
imagea picture: url, or base64 in content
videoa clip: url, or base64 in content
audioa recording: url, or base64 in content
speechaudio meant to be transcribed rather than described
passagespieces of text to rank or compare, rather than read as one
filea document such as a PDF: url only, never content

Two ways to supply one

import { readFileSync } from "node:fs";

await assistant.generate({
  inputs: [
    { type: "text",  content: "What changed between these two?" },
    { type: "image", url: "https://example.com/before.png" },      // fetched for you
    { type: "image", content: base64Png, mime: "image/png" },      // already in hand
    // A local file is content too — read it yourself, there is no "path" input:
    { type: "image", content: readFileSync("./after.png").toString("base64"), mime: "image/png" },
  ],
});
import base64
from pathlib import Path

assistant.generate(inputs=[
    {"type": "text", "content": "What changed between these two?"},
    {"type": "image", "url": "https://example.com/before.png"},          # fetched for you
    {"type": "image", "content": base64_png, "mime": "image/png"},       # already in hand
    # A local file is content too — read it yourself, there is no "path" input:
    {"type": "image", "content": base64.b64encode(Path("after.png").read_bytes()).decode(),
     "mime": "image/png"},
])
Set mime when you pass raw content

With a url the type is worked out for you from what the server fetches. With base64 in content — your own bytes, or a file you just read — there is nothing to work it out from, so set mime yourself.

Order is meaning

Inputs are read in the order you give them. Put the question before the material when you want it read with that question in mind, and after when you want an unprompted description first.

passages is not just more text

Several text inputs are one body to read. passages is a set of separate items to be ranked or compared — which is what a reranking call needs.

await reranker.generate({
  inputs: [
    { type: "text", content: "Which of these answers the question best?" },
    { type: "passages", content: [chunkA, chunkB, chunkC] },
  ],
});
reranker.generate(inputs=[
    {"type": "text", "content": "Which of these answers the question best?"},
    {"type": "passages", "content": [chunk_a, chunk_b, chunk_c]},
])