Use the OpenAI SDK with FastMetal: change base_url and api_key
Two settings change
FastMetal speaks the OpenAI API, so the official SDK works as it is. To switch, change two settings:
- the base URL, to
https://api.fastmetal.ai/v1 - the API key, to a FastMetal key
Then set model to a FastMetal model id. Calls such as chat.completions.create and the response objects stay the same, so the rest of your code does not move.
Create a key on the keys page. One key reaches every model in the catalog; the model parameter picks which one runs. The base URL ends in /v1, and leaving that off is the most common mistake.
Python
This uses the openai package, version 1.x or later (pip install openai).
from openai import OpenAI
client = OpenAI(
base_url="https://api.fastmetal.ai/v1",
api_key="sk-...", # your FastMetal API key
)
resp = client.chat.completions.create(
model="anthropic-claude-haiku-4-5",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello"},
],
)
print(resp.choices[0].message.content)
Node.js and TypeScript
Install with npm install openai. The option names differ from Python: baseURL (capital URL) and apiKey.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.fastmetal.ai/v1",
apiKey: process.env.FASTMETAL_API_KEY,
});
const resp = await client.chat.completions.create({
model: "anthropic-claude-sonnet-4-6",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Hello" },
],
});
console.log(resp.choices[0].message.content);
Keep the URL and key in environment variables
Both SDKs read OPENAI_BASE_URL and OPENAI_API_KEY on their own. Set them and you can construct the client with no arguments: OpenAI() in Python, new OpenAI() in Node.
export OPENAI_BASE_URL="https://api.fastmetal.ai/v1"
export OPENAI_API_KEY="sk-..."
This keeps the key out of source control and lets development and production point at different endpoints with no code change. It also fits how CI systems and containers already pass secrets.
Troubleshooting
Almost every failed switch is one of these.
| Symptom | Cause | Fix |
|---|---|---|
| 404 Not Found | The base URL is missing /v1, or has an extra path after it | Use exactly https://api.fastmetal.ai/v1 |
| An error saying the model is invalid or not found | model is still an OpenAI name such as gpt-4o | Use a FastMetal id from the model catalog, for example anthropic-claude-haiku-4-5 |
| A parameter is ignored or rejected | The request sends a field specific to one vendor | Stick to the standard fields (messages, temperature, max_tokens and so on) and drop the rest |
| 401 Unauthorized | The key is still the OpenAI key, or the variable is empty | Use the FastMetal key and check that the environment variable is set in the process that runs the code |
You can list the model ids your key can call with the SDK (client.models.list()) or with curl:
curl https://api.fastmetal.ai/v1/models -H "Authorization: Bearer $FASTMETAL_API_KEY"
FAQ
How much of my OpenAI code do I need to change?
The base URL, the API key and the model value. How you build requests and read responses stays the same.
Do streaming and tool calling work?
Yes. Streaming, tool calling and structured output work in the OpenAI format. stream=True streams exactly as it does against OpenAI. For the full tool loop, see tool calling in four steps, and for JSON output, structured output.
Can one key call several models?
Yes. Keep the same key and change the model id: Claude, GLM, DeepSeek and the rest of the catalog. The ids are on the model catalog.
Next steps
Create a key on the keys page and run one of the samples above. If you have not added credit yet, gemini-flash-lite-free costs $0 and answers without a balance. The model catalog lists every id, pricing shows the per-million-token rates, and the docs cover authentication and parameters.