Docs

API compatibility

One public URL speaks OpenAI, Anthropic and Gemini. Use the SDK you already have and change the base URL and the key.

Requests are routed by model name. The model must be served by at least one online machine in your workspace. Use /p/<providerId> after the slug to target a specific provider.

Authentication

Send your token in any of: Authorization: Bearer, x-api-key, x-goog-api-key or x-token. Authenticated callers use their own account token. Anonymous sessions use the auto-generated token from the CLI.

OpenAI

python
from openai import OpenAI

client = OpenAI(
    base_url="https://tunnel.tokmine.ai/t/<slug>/v1",
    api_key="<your token>",
)
resp = client.chat.completions.create(
    model="llama3.2",
    messages=[{"role": "user", "content": "Hello"}],
)

Anthropic

python
import anthropic

client = anthropic.Anthropic(
    base_url="https://tunnel.tokmine.ai/t/<slug>",
    api_key="<your token>",
)
msg = client.messages.create(
    model="llama3.2",
    max_tokens=256,
    messages=[{"role": "user", "content": "Hello"}],
)

Gemini

python
from google import genai
from google.genai import types

client = genai.Client(
    api_key="<your token>",
    http_options=types.HttpOptions(base_url="https://tunnel.tokmine.ai/t/<slug>"),
)
resp = client.models.generate_content(model="gemma3", contents="Hello")

JavaScript

javascript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://tunnel.tokmine.ai/t/<slug>/v1",
  apiKey: process.env.TOKMINE_TOKEN,
});

Setting up a coding tool or chat UI instead of an SDK? See AI tools and clients.

Supported dialects and paths

DialectBase URLNotes
OpenAI<url>/v1Chat completions, completions, embeddings, models. Streaming (SSE) supported.
Anthropic<url>Messages API. Requires the machine's runner to expose an Anthropic-compatible endpoint.
Gemini<url>generateContent and streamGenerateContent under /v1beta.
Ollama native<url>/apiPassed through to Ollama runners.

Only allow-listed API paths for each dialect are forwarded. A request whose dialect the chosen runner does not speak returns a clear error in the caller's own dialect.