Meta (Llama models) — quickstart
Open weights, runnable in your own infrastructure, no per-token API tax. Pick when you need full inference control (privacy, latency, custom fine-tuning), or when you want to avoid the closed-model lock-in.
meta-llama/llama-4-maverick Get a key
- Meta doesn't ship a first-party hosted API. Use one of: OpenRouter (router across providers), Together AI, Groq (fastest), Fireworks, or self-host via vLLM / Ollama.
- This guide uses OpenRouter (simplest cross-host adapter). Get a key at openrouter.ai.
- Set `OPENROUTER_API_KEY` env var.
Make a request
Three equivalent ways to call the recommended model. Pick the one that matches your stack.
curl
curl https://openrouter.ai/api/v1/chat/completions \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "meta-llama/llama-4-maverick",
"messages": [
{"role": "user", "content": "Summarize the last week of AI model releases."}
]
}' python
pip install openai # Using OpenAI SDK pointed at OpenRouter (it's OpenAI-compatible).
from openai import OpenAI
client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key=__import__("os").environ["OPENROUTER_API_KEY"],
)
res = client.chat.completions.create(
model="meta-llama/llama-4-maverick",
messages=[{"role": "user", "content": "Summarize the last week of AI model releases."}],
)
print(res.choices[0].message.content) node
npm install openai // Using OpenAI SDK pointed at OpenRouter (it's OpenAI-compatible).
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://openrouter.ai/api/v1",
apiKey: process.env.OPENROUTER_API_KEY,
});
const res = await client.chat.completions.create({
model: "meta-llama/llama-4-maverick",
messages: [{ role: "user", content: "Summarize the last week of AI model releases." }],
});
console.log(res.choices[0].message.content); Pricing
Hosted Llama via OpenRouter / Together / Groq is dramatically cheaper than closed-model APIs at comparable scale. Self-hosted is free per-token but you pay GPU-hours.
Alternatives in this lineup
- Llama 4 Scout — Smaller Llama 4 variant; cheaper, still 10M context.
- Llama 3.3 70B — Prior-gen 70B; well-supported across hosts; cheapest serious open-weight model.
Gotchas
- No first-party API. Meta releases the weights, doesn't run the API. Quality of hosted endpoints varies by provider — Groq is fastest, Together is broadest, Fireworks balances. Pick deliberately.
- Context-window throughput differs by host. Llama 4's nominal 10M context is real, but many hosts cap their actual offering at 128K or 1M for throughput reasons. Check your provider's published limit.
- Tool-use is less mature. Llama models support tool-use but the calling conventions are less battle-tested than the closed-model equivalents. Validate strictly.
Official docs: https://www.llama.com/docs/overview