NewHow we catch a seller listing the wrong model, and refund you if one does.

OpenAI SDK

MartLLM implements the OpenAI Chat Completions API. Any code that uses the official openai SDK (or a compatible client) works by setting two things:

  • base_url / baseURL → https://api.martllm.com/v1
  • api_key / apiKey → your ull_ key

Everything else — messages, tools, response_format, stream, max_tokens, temperature — is unchanged.

Python

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.martllm.com/v1",
    api_key=os.environ["UBERLLM_API_KEY"],
)

# Non-streaming
resp = client.chat.completions.create(
    model="deepseek/deepseek-v4-flash",
    messages=[{"role": "user", "content": "Explain rope embeddings briefly."}],
)
print(resp.choices[0].message.content)
print(resp.usage)  # prompt_tokens / completion_tokens are returned per request

# Streaming
stream = client.chat.completions.create(
    model="deepseek/deepseek-v4-flash",
    messages=[{"role": "user", "content": "Count to five."}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="", flush=True)

TypeScript / JavaScript

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.martllm.com/v1",
  apiKey: process.env.UBERLLM_API_KEY,
});

const resp = await client.chat.completions.create({
  model: "deepseek/deepseek-v4-flash",
  messages: [{ role: "user", content: "Explain rope embeddings briefly." }],
});
console.log(resp.choices[0].message.content);

Tool calling

Tool/function calling passes through unchanged. Use models that advertise tool support (see Models & routing; the catalog marks supports_tools).

resp = client.chat.completions.create(
    model="deepseek/deepseek-v4-flash",
    messages=[{"role": "user", "content": "What is the weather in Paris?"}],
    tools=[{
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get the current weather for a city",
            "parameters": {
                "type": "object",
                "properties": {"city": {"type": "string"}},
                "required": ["city"],
            },
        },
    }],
)
print(resp.choices[0].message.tool_calls)

A reply that calls a tool always ends with finish_reason: "tool_calls" (stop_reason: "tool_use" on /v1/messages), streamed or not, whichever provider served it. Send each tool call back as you got it: some carry an extra_content field (Gemini's thought signature) that the model needs on the next turn.

Reply shape

Every reply has the same fields whichever provider served it: the OpenAI chat completion fields (id, object, created, model, choices, usage) and our usage.cost_usd. Fields a provider adds of its own (x_groq, service_tier, system_fingerprint, usage.queue_time and the like) are removed.

Reasoning models send their reasoning in both reasoning and reasoning_content, with the same text, in message (or delta when streaming), so a client that reads either one gets it. When a provider sends OpenRouter-style reasoning_details, they pass through unchanged. A reply with no reasoning has neither field.

Request fields a provider refuses but that only tune the answer (reasoning, thinking, verbosity, top_k and similar) are dropped for that provider, and reasoning: {"effort": "low"} is sent as reasoning_effort when that is what it takes. Message content sent as a list of text parts goes as one string to a provider that only takes strings. A picture, audio or file sent to a model that reads only text is refused with a plain 400 that says so: check input_modalities in GET /v1/models first.

Listing models

curl https://api.martllm.com/v1/models \
  -H "Authorization: Bearer $UBERLLM_API_KEY"

Returns the OpenAI list shape ({"object":"list","data":[{"id": "...", ...}]}) with the chat models you can call now; ?type=all adds image, video, music and speech models. Each chat model carries context_length, max_output_tokens, input_modalities, supports_tools, supports_reasoning, supports_vision and supported_parameters (see Models & routing). The public catalog (no auth) is also at GET /api/v1/public/models with per-endpoint pricing.

Streaming usage

For streaming requests MartLLM automatically asks for token usage (stream_options.include_usage), so the final chunk carries a usage object with cost_usd, what the call is billed in US dollars. A reply that is not streamed has usage.cost_usd too, and the X-UberLLM-Cost-USD header (except a slow one that already started with keepalive spaces: then only the body field). Your bill is the cost the marketplace reports for that call. The reply does not wait for that report: when it is not in yet, cost_usd is our estimate, and your balance and Dashboard → Activity show the exact charge a moment later. If usage is ever missing, MartLLM falls back to a tokenizer estimate — such rows are flagged in Dashboard → Activity.

Responses API

client.responses.create and client.responses.stream work too, on every chat model: text, tool calls (function_call → function_call_output), structured output and streaming. MartLLM stores nothing, so send the whole conversation in input each call instead of previous_response_id. Details: Responses API.

r = client.responses.create(
    model="deepseek/deepseek-v4.1-flash",
    instructions="Answer in one short sentence.",
    input="What is the capital of France?",
)
print(r.output_text)

Notes

  • The trailing /v1 is required in the base URL.
  • Each request is sent to an available third-party provider for the model and is billed what the provider charged, with no MartLLM fee. See Pricing.
  • For automatic retries and the routing options MartLLM accepts, see Models & routing.