On this pageEndpoints and protocols
Back to docs

Endpoints and protocols

Match endpoints to model capabilities.

Choose a model that supports your endpoint, tools and input types. Chat Completions, Responses and Messages have different schemas; changing the path alone is insufficient.

API endpoints

MethodPathDescribe
POST/v1/messagesAnthropic Messages API (recommended)
POST/v1/chat/completionsOpenAI Chat Completions (compatible)
POST/v1/images/generationsOpenAI Images Generations (req/gpt-image-2)
POST/v1/images/editsOpenAI Images Edits / reference image (req/gpt-image-2)
POST/v1/audio/speechSpeech API: use only when a Text-to-speech model is listed. An existing endpoint does not mean every model supports it.
POST/v1/videosOpenAI Videos — create a video
GET/v1/videos/{id}Poll video progress (no extra charge)
GET/v1/videos/{id}/contentDownload the MP4 (no extra charge)
DELETE/v1/videos/{id}Cancellation depends on the route and job state; the Seedvis route currently does not support DELETE. Cancellation does not guarantee a refund.
POST/v1/responsesOpenAI Responses API (compatible)
GET/v1/modelsList of models and prices
POST/v1/messages/count_tokensToken estimation (free)

View the full guide

/v1/messages/count_tokens

This endpoint provides a free local estimate, not the model’s official tokenizer. input_tokens is capped at 200,000, so do not use it to confirm that a large prompt fits the context window or to finalize a cost estimate. Compare against actual generation usage. The JSON below is illustrative, not a live response.

curl --fail-with-body "https://vietrouter.com.vn/v1/messages/count_tokens" \
  -H "x-api-key: ${STALI_API_KEY:?STALI_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-fable-5","messages":[{"role":"user","content":"Hello"}]}'

Responses and tool calling

The Responses example uses POST /v1/responses and carries context in input. This documentation does not promise unpublished response storage, retrieval or listing operations.

import os
from getpass import getpass
from openai import OpenAI

client = OpenAI(api_key=os.getenv("STALI_API_KEY") or getpass("STALI_API_KEY: "), base_url="https://vietrouter.com.vn/v1", max_retries=0)
stream = client.responses.create(model="gpt-5.6-sol", input="Hello", stream=True, store=False)
completed = False
for event in stream:
    if event.type == "response.output_text.delta":
        print(event.delta, end="", flush=True)
    elif event.type == "response.completed":
        completed = event.response.status == "completed"
    elif event.type in ("error", "response.failed", "response.incomplete"):
        raise RuntimeError(str(event))
if not completed:
    raise RuntimeError("Stream ended without response.completed; preserve the request ID and check usage before retrying.")

The JSON samples target Chat Completions and Messages respectively. The Python samples show a complete tool roundtrip with local addition: validate the name and arguments, execute the function and send its result with the matching call ID. The gateway does not run the function. Each model round can incur a separate charge; these examples cap execution at 4 rounds and disable automatic SDK retries.

Examples receive source review and local checks; this does not establish compatibility with every app version. Check settings, send a small request and confirm usage before production use.

Zalo groupWhatsApp