RelayPointdocs

Products

Chat & text

OpenAI-compatible chat completions, streaming, output limits and how the cost is held and settled.

POST /v1/chat/completions takes the OpenAI chat format. Set model to a RelayPoint text product. Messages can include images as image_url parts. Supported options: max_tokens (or max_completion_tokens), temperature, top_p, stop, seed, response_format (text, json_object or json_schema), tools, tool_choice, parallel_tool_calls, stream and user. Other OpenAI fields are ignored. Scope: chat.

curl https://api.relaypoints.online/v1/chat/completions \
  -H "Authorization: Bearer $RELAYPOINT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "rp/text-pro",
    "messages": [
      { "role": "system", "content": "You write short property listings." },
      { "role": "user", "content": "3-bed house with a garden in Durban North." }
    ],
    "max_tokens": 400,
    "temperature": 0.7
  }'

Output limits

Each product has a default and a maximum number of output tokens. Without max_tokens, the default applies; asking for more than the maximum returns 400 invalid_request. GET /v1/models returns both values as default_max_tokens and max_tokens.

ProductDefault max_tokensMaximum
rp/text-pro4,09616,384
rp/text-fast2,0488,192
rp/text-max4,09632,768

How a call is charged

  1. Before the call, RelayPoint estimates the worst case: the prompt (images count as about 1,500 tokens each) plus the maximum output (max_tokens, or the product default).
  2. That amount is held in your wallet. If the wallet (or a spend cap) can't cover it, the call is refused with 402 before any model runs.
  3. After the call, you are charged for the tokens actually used and the rest of the hold is released. usage.cost_usd shows the final price.
  4. If the call fails, the hold is released and nothing is charged.

Streaming

With "stream": true the response is text/event-stream. Each event is a chat.completion.chunk; the last chunk before data: [DONE] carries finish_reason and usage with the final cost. If the model fails mid-stream, an event with an error object is sent and you pay only for the text already delivered. If your client disconnects, generation stops and only what was produced is charged.

const stream = rp.chat.completions.stream({
  model: "rp/text-fast",
  messages: [{ role: "user", content: "Write a haiku about Maputo." }],
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
  if (chunk.usage) console.log("\ncost:", chunk.usage.cost_usd);
}
Text
data: {"id":"chatcmpl-…","object":"chat.completion.chunk","model":"rp/text-fast","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}

data: {"id":"chatcmpl-…","object":"chat.completion.chunk","model":"rp/text-fast","choices":[{"index":0,"delta":{"content":"Harbour"},"finish_reason":null}]}

data: {"id":"chatcmpl-…","object":"chat.completion.chunk","model":"rp/text-fast","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":15,"completion_tokens":19,"total_tokens":34,"product":"rp/text-fast","units":0.034,"unit":"1k_tokens","cost_usd":"0.000020"}}

data: [DONE]

Tool calling

Send tools (OpenAI function definitions with a JSON schema for the arguments) and tool_choice (auto by default, none, required or one named function). When the model wants a tool, the answer has content: null, finish_reason: "tool_calls" and message.tool_calls, each with a unique id and its arguments as a JSON string. Several calls can come in one answer; parallel_tool_calls: false asks for at most one.

{
  "model": "rp/text-pro",
  "max_tokens": 1500,
  "tool_choice": "auto",
  "messages": [
    { "role": "system", "content": "You qualify sales leads." },
    { "role": "user", "content": "Check Acme Logistics against our profile." }
  ],
  "tools": [
    { "type": "function", "function": {
        "name": "crm_read",
        "description": "Find CRM contacts by name, company, e-mail or stage.",
        "parameters": { "type": "object", "properties": { "query": { "type": "string", "maxLength": 200 } }, "required": ["query"] } } }
  ],
  "response_format": { "type": "json_schema", "json_schema": { "name": "output", "schema": { "type": "object", "properties": { "status": { "type": "string" } }, "required": ["status"] } } }
}

Run the tool yourself, then send the conversation back with the assistant message (its tool_calls unchanged) and one role: "tool" message per call, with its tool_call_id. RelayPoint passes tool results to the model unchanged. With response_format: json_schema, the final answer is one JSON object in content.

JSON
[
  { "role": "assistant", "content": null, "tool_calls": [{ "id": "call_3f9a1c0d2b7e", "type": "function", "function": { "name": "crm_read", "arguments": "{\"query\":\"Acme Logistics\"}" } }] },
  { "role": "tool", "tool_call_id": "call_3f9a1c0d2b7e", "content": "{\"contacts\":[{\"name\":\"Acme Logistics\",\"stage\":\"lead\"}]}" }
]
  • usage is on every answer, tool-call turns included, with product, units (thousands of tokens), unit and cost_usd.
  • Tool calls are not streamed: send stream: false with tools.
  • With a test key the sample model calls the first tool (or the one you force) with arguments built from its schema, then answers with a JSON object that matches your json_schema once a tool result is back.