Token Factory
Token Factory lets you call leading open-weight models, such as DeepSeek, Qwen, GLM and Gemma, with one API request. The models are already running on Jarvislabs GPUs, and we have tuned each one to run as efficiently as possible. You send a request with your API key, get the reply, and pay only for the tokens that you use.
- Nothing to set up. There are no GPUs to start, scale or shut down. Create an API key and send your first request in minutes.
- Pay per token. You pay for input, cached input and output tokens from your Jarvislabs wallet. When you send nothing, you pay nothing.
- Works with your tools. The API follows the OpenAI Chat Completions format. The OpenAI SDKs, and most apps and coding agents that work with OpenAI, work with Token Factory after you change the base URL and the API key.
- Your data stays private. The models run on our GPU servers in India. We don't store your prompts or replies, and we don't train on them. See Data privacy and regions.
Token Factory is in beta, so its features and limits can change.
| Item | Details |
|---|---|
| Base URL | https://models.jarvislabs.net/v1 |
| Authentication | Authorization: Bearer <your API key> |
| API routes | POST /chat/completions, GET /models, GET /models/{model_id}, GET /usage/overview, GET /usage/models. GET /public/models lists models and prices without an API key. |
| Billing | Per million input, cached input and output tokens, paid from your Jarvislabs wallet |
| Where models run | On Jarvislabs GPU servers in India. See Data privacy and regions. |
If you want a model on GPUs that serve only your traffic, with capacity that you control, use Managed Endpoints. To serve a model that isn't in our catalog, use Serverless. The comparison table shows the differences.
Quickstart
1. Create an API key
In the dashboard, click your profile picture at the top right, choose Settings, then open the API Keys tab. You can also open the page directly. Enter a name for the key and click Generate API Key.
- The API Keys tab in Settings.
- Enter a name and click Generate API Key.
Copy the key when it appears. The dashboard shows it only once. You can have up to 5 active keys, and you can expire a key at any time. The same key works for Token Factory, Managed Endpoints, Serverless, the jl CLI and the Python SDK.
Anyone who has your key can spend your credit. Keep it in an environment variable or a secret manager, and never put it in browser or mobile app code.
2. Add credit
Token Factory takes payment from your Jarvislabs wallet, the same wallet that pays for GPU instances. If your account has no Token Factory credit, grants or balance, recharge your wallet before your first request. Without credit, requests fail with HTTP 402.
3. Send your first request
Save your key in an environment variable. This page uses the name JARVISLABS_API_KEY. Any name works, as long as your code uses the same one.
export JARVISLABS_API_KEY="<your API key>"
Then call a model. This example uses gemma-4-31b-it. You can use any model ID from the catalog.
- cURL
- Python
- TypeScript
- jl CLI
curl https://models.jarvislabs.net/v1/chat/completions \
-H "Authorization: Bearer $JARVISLABS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma-4-31b-it",
"messages": [{"role": "user", "content": "Write one sentence about the monsoon."}],
"max_tokens": 1024
}'
pip install openai
import os
from openai import OpenAI
client = OpenAI(
base_url="https://models.jarvislabs.net/v1",
api_key=os.environ["JARVISLABS_API_KEY"],
)
response = client.chat.completions.create(
model="gemma-4-31b-it",
messages=[{"role": "user", "content": "Write one sentence about the monsoon."}],
max_tokens=1024,
)
print(response.choices[0].message.content)
npm install openai
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://models.jarvislabs.net/v1",
apiKey: process.env.JARVISLABS_API_KEY,
});
const response = await client.chat.completions.create({
model: "gemma-4-31b-it",
messages: [{ role: "user", content: "Write one sentence about the monsoon." }],
max_tokens: 1024,
});
console.log(response.choices[0].message.content);
uv tool install jarvislabs # or: pip install jarvislabs
jl setup # paste your API key when it asks
jl models chat gemma-4-31b-it "Write one sentence about the monsoon."
The reply is a standard Chat Completions object. The usage field shows the tokens that you pay for.
max_tokensmax_tokens sets the longest reply that the model can write. You can send max_completion_tokens instead, but not both. On models that think before they answer, the thinking also counts toward this limit. Set a value that leaves room for both, so that you control the length of replies and your cost.
Choose a model
The Token Factory catalog in the dashboard lists every model you can call.
-
Each model card shows:
- The model name, and the model ID that you send in requests.
- The precision that we serve the model in, such as
FP8orBF16. - A short description of the model.
- Its capabilities: Reasoning means that it can think before it answers, Vision means that it accepts images, Tools means that it supports tool calling, and JSON means that it can return JSON that matches a schema.
- The input and output prices per million tokens, and the context length.
Click a card to open the model page, which has the full details and code to call the model.
-
Usage shows your token use and cost. See Track usage and cost.
-
Playground opens a chat window where you can try any model. See Try models in the playground.
The model page has everything you need to call that model:
- The model ID. Click the copy icon to copy it.
- The prices for input, output and cached input tokens, the context length, the Reasoning (thinking) support, the input and output types, the developer, the precision and the capabilities.
- The base URL, the model ID and the header for your API key. Code examples for cURL, Python and TypeScript follow.
- API keys opens the page where you create a key.
You can also list the models from code or from the terminal:
- cURL
- Python
- jl CLI
curl https://models.jarvislabs.net/v1/models \
-H "Authorization: Bearer $JARVISLABS_API_KEY"
for model in client.models.list().data:
print(model.id)
jl models list # every model, with context length and prices
jl models get gemma-4-31b-it # one model, with ready-to-run code
Each entry from GET /models has the model's context_length, pricing, input_modalities, capabilities (tool calling and JSON output) and thinking settings.
We add new models and retire old ones over time. When a model is retired, requests that use its ID fail with HTTP 404. Check the catalog for the current list.
Features
Use the Chat Completions parameters that your model supports, such as temperature, top_p, stop and seed. The catalog shows which of the features below each model supports.
Streaming
Set stream to true to receive the reply as server-sent events while the model writes it. Add stream_options to get the token usage in the last chunk.
stream = client.chat.completions.create(
model="gemma-4-31b-it",
messages=[{"role": "user", "content": "Count from 1 to 5."}],
max_tokens=1024,
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
if chunk.usage:
print("\nTokens:", chunk.usage.prompt_tokens, "in,", chunk.usage.completion_tokens, "out")
Tool calling
Describe your functions in tools. When the model wants to call one, the reply has finish_reason set to tool_calls, and message.tool_calls holds the function name and its arguments as JSON. Your code runs the function and sends the result back in a tool message.
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city.",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}]
response = client.chat.completions.create(
model="gemma-4-31b-it",
messages=[{"role": "user", "content": "What is the weather in Pune right now?"}],
tools=tools,
max_tokens=1024,
)
call = response.choices[0].message.tool_calls[0]
print(call.function.name, call.function.arguments) # get_weather {"city": "Pune"}
JSON output
To get a reply that matches a JSON schema, set response_format:
import json
response = client.chat.completions.create(
model="gemma-4-31b-it",
messages=[{"role": "user", "content": "Give me a city in India and its state."}],
response_format={
"type": "json_schema",
"json_schema": {
"name": "city",
"schema": {
"type": "object",
"properties": {"city": {"type": "string"}, "state": {"type": "string"}},
"required": ["city", "state"],
},
},
},
max_tokens=1024,
)
print(json.loads(response.choices[0].message.content)) # {'city': 'Mumbai', 'state': 'Maharashtra'}
Thinking
Some models think before they answer. Thinking can give better answers to hard problems, but it uses output tokens and adds time. The dashboard calls this Reasoning.
Each model has its own thinking settings. The model page, jl models get <model_id> and the thinking field of GET /models show whether the model can think, whether you can switch thinking off, which effort levels it accepts, and the names of the settings. The settings go in chat_template_kwargs. With the OpenAI Python SDK, pass them through extra_body. For example, gemma-4-31b-it uses enable_thinking:
response = client.chat.completions.create(
model="gemma-4-31b-it",
messages=[{"role": "user", "content": "Is 221 a prime number?"}],
max_tokens=4096,
extra_body={"chat_template_kwargs": {"enable_thinking": False}},
)
When the model thinks, the reply has the thinking in message.reasoning_content, separate from the answer in message.content. When the model server reports it, usage.completion_tokens_details.reasoning_tokens shows how many output tokens the thinking used.
Images and video
Models whose catalog entry lists image input accept images as image_url parts in a message. The URL can be a public link, which the model server downloads, or a base64 data URL. Models that list video input accept video_url parts in the same way.
import base64
with open("photo.jpg", "rb") as f:
image_b64 = base64.b64encode(f.read()).decode()
response = client.chat.completions.create(
model="gemma-4-31b-it",
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "What is in this picture?"},
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image_b64}"}},
],
}],
max_tokens=1024,
)
Prompt caching
We handle prompt caching for you. When the start of your prompt matches a prompt that the model processed recently, we send your request to a server where that prompt is already cached. Those input tokens then cost the lower cached input price. There is nothing to set up, and there is no extra fee for writing to the cache. When the model server reports it, usage.prompt_tokens_details.cached_tokens shows how many of the prompt_tokens came from the cache.
Each account's cache is kept separate. Your requests reuse only prompts that your own account sent, so your cached prompts never speed up, or show up in, another account's requests. To split your own cache further, for example one cache for each of your end users, send a cache_salt string of 1 to 256 characters in the request body.
Coding agents. If you use a coding agent such as OpenCode or Pi, set up as described in OpenCode and Pi, caching works without any extra configuration.
Your own apps. To get the most cache hits in your own app:
- Put the parts of a prompt that don't change, such as the system prompt, instructions and long documents, at the start. Put the parts that change at the end.
- Send an
x-session-idheader with every request in a conversation. Use one ID for the whole conversation, such as a UUID that you create when the conversation starts, and a new ID for each new conversation. Some models use this ID to keep a conversation on the same server, which gives more cache hits.
import uuid
session_id = str(uuid.uuid4()) # one ID for this conversation
response = client.chat.completions.create(
model="gemma-4-31b-it",
messages=messages,
max_tokens=1024,
extra_headers={"x-session-id": session_id},
)
With cURL, add -H "x-session-id: <your conversation ID>".
What is not supported
- The OpenAI Responses API, the legacy Completions API, embeddings, audio and image generation are not available.
- Fine-tuned or custom models can't be added to Token Factory. To serve your own model, use Serverless.
Try models in the playground
The playground lets you chat with any model before you write code. It uses your wallet, at the same prices as the API.
- Choose the model.
- Switch thinking on or off, and choose the effort level, on models that support them.
- Set a system prompt, the maximum output tokens, temperature, top P and streaming. The settings panel opens from the icon at the top right.
- Last response shows the latency, the token counts and the cost of the last reply.
- View code gives you code that sends the same conversation, with the same settings, from your own app.
Track usage and cost
The Usage page shows how many tokens you used and what they cost, for each model.
- Show cost or tokens, for the last 24 hours, 7 days, 30 days or custom dates within the last 30 days.
- The number of requests, the cache hit rate (the share of input tokens that came from the cache), the money that caching saved, and the average cost per hour or per day.
- Cost or tokens over time, for each model. Click a model name in the legend to show only that model.
- The breakdown by model, or by hour or day.
The page calculates cost from your token counts and the price of each model at the time of the request. These numbers are for tracking. Your wallet charges are calculated separately and can differ. The page shows totals, not a list of individual requests.
You can read the same numbers from code. With an API key, the result covers only the requests made with that key, so you can track usage per key. This example asks for today and the previous 6 days:
curl -G https://models.jarvislabs.net/v1/usage/models \
-H "Authorization: Bearer $JARVISLABS_API_KEY" \
--data-urlencode "start=$(date -u -d '6 days ago' +%Y-%m-%dT%H:%M:%SZ)" \
--data-urlencode "end=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--data-urlencode "timezone=Asia/Kolkata"
On macOS, use date -u -v-6d instead of date -u -d '6 days ago'.
startandendare timestamps with a time zone. They must fall within today and the previous 29 days, andendcan't be in the future.timezonesets where each day starts. The default isUTC. The API widens the range to whole hours or days in this time zone.GET /usage/modelsreturns the totals for all models, and the totals for each model, 10 models per page. Uselimit(up to 100) andoffsetto get more.GET /usage/overviewreturns the totals over time, by hour (interval=hour, at most 168 hours) or by day (interval=day). Addmodelto show one model.
Use the CLI and SDK
The jl CLI covers the everyday tasks from the terminal:
uv tool install jarvislabs # install the CLI
jl setup # sign in with your API key
jl models list # models, context length and prices
jl models get <model_id> # details and ready-to-run code for one model
jl models chat <model_id> "Explain KV cache in two lines"
jl models chat # pick a model and chat in the terminal
cat notes.txt | jl models chat <model_id> "Summarize this"
jl models chat <model_id> "What is in this picture?" --image photo.jpg
Run jl models chat --help for every option, such as --system, --max-tokens, --no-thinking, --effort and --json. The CLI reference describes each command.
To use the Python SDK in your own project, install it there with pip install jarvislabs. It finds the key that jl setup saved:
from jarvislabs import Client
with Client() as client:
reply = client.models.chat(
"gemma-4-31b-it",
[{"role": "user", "content": "Hello"}],
max_tokens=1024,
)
print(reply["choices"][0]["message"]["content"])
Use a coding agent
jl setup offers to install a skill file that teaches coding agents, such as Claude Code, Codex, Cursor and OpenCode, how to use jl. When it asks, choose yes, and select each agent that you use. Then you can ask your agent in plain words, for example:
- "Which Token Factory models support tool calling, and what do they cost?"
- "How do I switch thinking off for
gemma-4-31b-it?"
See Using with AI coding agents for the setup. To use Token Factory models as the model inside a coding agent, see OpenCode and Pi.
Pricing and billing
- Each model has a price per million input tokens, cached input tokens and output tokens. The catalog, the pricing page and
jl models listshow the current prices. - Thinking tokens count as output tokens.
- We charge your wallet for the tokens every few minutes. Any Token Factory credit on your account is used first, then your grants, then your balance.
- Accounts billed in India pay in rupees. All other accounts pay in US dollars.
- You pay nothing while you aren't sending requests. There is no subscription or minimum spend.
Rate limits
For now, Token Factory has basic rate limits for each user. These limits can change.
If a request goes over a limit, it fails with HTTP 429. Wait a moment and send it again, with a longer wait after each try. If the response has a Retry-After header, wait at least that many seconds.
If you need higher limits, email support@jarvislabs.ai. Tell us the model, the traffic that you expect (requests per minute and tokens per request) and what you are building, and we'll reply with what we can offer.
Errors
Most errors come back as JSON with an HTTP status code:
{
"error": {
"code": "model_not_found",
"message": "Unknown model. See GET /v1/models.",
"type": "invalid_request_error",
"param": null,
"request_id": "6c6a96c685e44d389d121ff4cf8d01a7"
}
}
| Status | What it means | What to do |
|---|---|---|
400 | The request body is not valid, or the model rejected a parameter. | Fix the request. Check that max_tokens is not larger than the model's context length. |
401 | The API key is missing, wrong or expired. | Check the Authorization header and the key. |
402 | Your account has no credit. | Recharge your wallet. |
404 | The model ID does not exist, or the model was retired. | Check the ID in the catalog or with GET /models. |
408 | The request body did not arrive within 10 seconds. | Retry. Check your network connection. |
413 | The request body is larger than 16 MB. | Send smaller images, use image URLs, or shorten the prompt. |
422 | The parameters of a usage request are not valid. | Check start, end, interval and timezone. |
429 | You went over a rate limit. | Wait and retry. See Rate limits. |
500 | An unexpected error on our side. | Retry. If it keeps happening, contact support. |
502, 503, 504 | The model is busy, did not answer in time, or had a temporary problem. | Wait a few seconds and retry. If the response has a Retry-After header, wait that long. |
With stream set to true, errors from the model arrive as the last event of the stream, under status 200, and no [DONE] event follows. Errors from our own checks, such as 401, 402 and 429, still come back as status codes.
Responses from the API have an X-Request-ID header. When you contact support about a request, include it if the response has one.
FAQ
Do I need to rent a GPU to use Token Factory?
No. The models are already running. Create an API key, add credit and send a request.
Can I use the OpenAI SDK?
Yes, for Chat Completions. Set the base URL to https://models.jarvislabs.net/v1, use your Jarvislabs API key, and use a model ID from the catalog. The Responses API is not supported.
Can I use a model that is not in the catalog?
Not in Token Factory. You can deploy a model from our Managed Endpoints catalog on GPUs that serve only your traffic, or serve any Hugging Face or Ollama model with Serverless. If you want us to add a model to Token Factory, email support@jarvislabs.ai.
Why did a reply stop early?
Check finish_reason in the reply. If it is length, the reply reached max_tokens. Raise max_tokens, or switch thinking off if the model spent the limit on thinking. If a stream ended with an error event, retry, and send the X-Request-ID to support if it keeps happening.
What happens when a model is retired?
Requests that use its model ID fail with HTTP 404. Move to another model in the catalog. If you need help to choose one, email support@jarvislabs.ai.
Do you store my prompts, or train on them?
No. We don't store your prompts or replies, and we don't use them to train models. We keep only request metadata, such as token counts, for billing and usage reports. See Data privacy and regions.
Where do the models run?
On Jarvislabs GPU servers in data centres in India. See Data privacy and regions.