Cost optimization
What actually drives your bill, and which levers move it.
What drives the bill?
Token count times model price. For most workloads the token count is dominated by what you resend, not by what you newly write: conversation history, retrieved RAG chunks, and system prompts are re-billed on every turn.
Which lever moves it most?
Usually model choice. The per-1M-token spread between a flagship and a small model is often an order of magnitude, while the quality difference on routine work (classification, extraction, translation, short edits) is far smaller. The Models page shows input and output prices side by side with the official rate, so the comparison is concrete.
Does output cost more than input?
Usually yes, often several times more. Workloads that generate long responses are therefore sensitive to output price specifically — check the output column, not just the input one.
Do failed requests cost anything?
No. Failures, timeouts, and cancelled generations that never completed upstream are not billed. You are charged when a response actually comes back.
Are metadata calls billed?
No. GET /v1/models is a metadata query and is free. Client "test connection" buttons
usually hit it, which is why a passing connection test does not prove you have balance.
How do I attribute spend?
Create one key per project or environment. Per-key spend is visible in the console, so attribution is a matter of having split the keys up front — it cannot be reconstructed afterwards from a single shared key.