Your first chat completion with FastMetal: a 5-minute curl quickstart
Four steps
This walks from a new account to a working chat completion with curl. The endpoint is OpenAI-compatible, so if you have called OpenAI before, everything here will look familiar, and if you have not, every command can be pasted as it is.
- Get an API key.
- Add credit, or pick a free model.
- Send a request.
- Read the response.
1. Get an API key
Sign in and open the keys page. A key starts with sk- (keys on a USD account start with sk-usd-), and one key can call every model in the catalog.
The full key is shown once. Copy it when you see it. For the command line, put it in an environment variable rather than pasting it into each command:
export FASTMETAL_API_KEY="sk-..."
2. Add credit, or pick a free model
FastMetal is prepaid: you add credit, and each request draws down the balance by the tokens it uses. When the balance runs out, requests are refused; nothing is billed later. On a USD account the minimum top-up is $5, by card. The per-million-token rates for each model are on pricing.
A new account starts with no credit. A paid model refuses requests until you add some, with budget_exceeded in the error body. To test the plumbing first, use gemini-flash-lite-free: it costs $0 and answers without a balance.
3. Send the first request
POST to /v1/chat/completions. Two headers matter: Authorization with the key after Bearer , and Content-Type: application/json.
curl https://api.fastmetal.ai/v1/chat/completions \
-H "Authorization: Bearer $FASTMETAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic-claude-haiku-4-5",
"messages": [
{"role": "user", "content": "Describe FastMetal in one sentence."}
]
}'
messages is the conversation, as an array. Each entry has a role: user for the person asking, assistant for earlier model replies, and system for instructions on how the model behaves. One user message is enough to start. To try it with no credit, change model to gemini-flash-lite-free.
4. Read the response
The JSON looks roughly like this. The reply text is in choices[0].message.content.
{
"id": "chatcmpl-...",
"object": "chat.completion",
"model": "anthropic-claude-haiku-4-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "FastMetal is an AI gateway: one API key and one endpoint for models from many providers."
},
"finish_reason": "stop"
}
],
"usage": {"prompt_tokens": 22, "completion_tokens": 18, "total_tokens": 40}
}
Two other fields are worth knowing from the start:
finish_reasonisstopwhen the model finished on its own, andlengthwhen it hit the token limit and was cut off.usagecounts the tokens the request used. Input (prompt_tokens) and output (completion_tokens) are billed at the model's per-million-token rates, and the request's cost comes off your balance.
When it fails
Most first attempts that fail hit one of these.
| Error | Usual cause | Fix |
|---|---|---|
401 Unauthorized | Wrong key, missing Bearer , or an empty environment variable | Run echo $FASTMETAL_API_KEY and check the header reads Authorization: Bearer sk-... |
budget_exceeded in the body | No credit, or the balance is used up | Add credit from the billing page, or switch to gemini-flash-lite-free |
| An error saying the model is invalid | The model value has a typo or is not a FastMetal id | Copy the id from the model catalog |
A 400 usually means the JSON in -d is malformed: look for a missing comma or an unclosed quote. If the request hangs with no response, suspect the network or a timeout and send it again.
From curl to code
Anything that works in curl works the same in code. Point the official OpenAI SDK at https://api.fastmetal.ai/v1 with your FastMetal key, pass messages, and read choices[0].message.content. The OpenAI SDK guide has Python and Node.js examples, and streaming in Python shows how to print tokens as they arrive.
FAQ
If I create a new key, does the old one stop working?
No. Existing keys keep working. To revoke a key you no longer need, delete it on the keys page.
Can one key call several models?
Yes. Change model in the request and the same key calls any model in the catalog.
Can I try it for free?
Free models such as gemini-flash-lite-free cost $0 and work without credit. Paid models need prepaid credit, from $5 on a USD account. Rates are on pricing.
Next steps
- Change
modelto another model and compare the answers. - Call the same endpoint from the OpenAI SDK.
- Read the docs for every parameter.