What is relayfor.si?

Tools and structured output

Let the model call your functions, or answer in the exact JSON you need.

Function calling

Describe your functions in tools. The model answers with the calls it wants; your code runs them and sends the results back.

const reply = await ai.chat.completions.create({
  model: "anthropic/claude-sonnet-5.5",
  max_tokens: 1024,
  messages: [{ role: "user", content: "How many holders does $NOVA have?" }],
  tools: [
    {
      type: "function",
      function: {
        name: "token_holders",
        description: "How many wallets hold a Solana token right now",
        parameters: {
          type: "object",
          properties: { mint: { type: "string" } },
          required: ["mint"],
        },
      },
    },
  ],
});

const call = reply.choices[0]?.message.tool_calls?.[0];

Tools work the same on Responses and on Messages, in each format's own shape. Each model's GET /models entry says what it supports.

Structured output

Ask for JSON that matches your schema with response_format:

{
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "day_summary",
      "strict": true,
      "schema": {
        "type": "object",
        "properties": {
          "trades": { "type": "integer" },
          "volume_sol": { "type": "number" }
        },
        "required": ["trades", "volume_sol"],
        "additionalProperties": false
      }
    }
  }
}

Add :online to a model id and it searches the web first, then answers with what it found:

{
  "model": "google/gemini-3.8-flash:online",
  "messages": [{ "role": "user", "content": "What happened on Solana this week?" }],
  "max_tokens": 1024
}

Each search is charged at the model's search price (web_search in GET /models), on top of the tokens. Models with hosted web search and web fetch tools can use those too: they run in a loop, so set max_tool_calls to cap the steps and the reserve.

Tools we don't serve

Nothing is kept between calls, so tools that keep files, memory or a sandbox, or that run other models inside a call, are refused with 400 tool_not_served:

  • hosted code execution, shells and code interpreters
  • file search, files, memory and the text editor tool
  • image generation tools and tools that call other models (to make images, call POST /images)
  • X search, which bills per post with no limit a request can set

Tools your code runs on its own machine always work.

Cap tool loops

Hosted tools like web search run in a loop, and the reserve covers every possible step. Set max_tool_calls (or the tool's max_uses) to keep it small. A loop with no step limit is refused.

On this page