EN ▾
Create key

Estimating Llama API Key Costs per 1M Tokens

Developers often ask how to budget for high-volume text generation without hidden fees. This article teaches a method to calculate expenses using our $0.15 per 1M input and $0.50 per 1M output rates, including a worked example for a typical chat application.

Developer workspace with token cost calculator and crypto coins

Understanding the Pricing Model

Our API uses a straightforward prepaid credit model based on token consumption. You pay $0.15 for every one million input tokens and $0.50 for every one million output tokens. This means you only pay for the actual data processed, not for the time your key is active. There are no monthly subscriptions or hidden fees attached to your account.

Errors and refusals are free of charge. If your request fails due to a network issue or if the model refuses a prompt, you are not charged for those tokens. This ensures that your budget is spent only on successful interactions. The prepaid credit you purchase never expires, allowing you to use it at your own pace.

When you sign up, you receive $0.50 of trial credit without needing to enter a credit card. This allows you to test the API and understand the token consumption before committing to a larger top-up. The key is shown immediately after signup, so you can start testing right away.

Top-ups are processed using cryptocurrency only. You can pay with USDT on the TRC20 network or USDC on the Base network. The minimum top-up amount is $20, and the maximum is $500. This method ensures fast processing and lower fees compared to traditional banking methods. You can choose any whole amount within this range.

Calculating Input Token Costs

Input tokens include the prompt you send to the model, such as the user message and system instructions. Our API charges $0.15 per one million input tokens. To estimate your costs, you need to count the tokens in your prompts and multiply by this rate. This rate is consistent regardless of the model's internal architecture.

For example, if your application sends an average of 1,000 tokens per request, you can calculate the cost per request by dividing 1,000 by 1,000,000 and then multiplying by $0.15. This gives you a very small fraction of a cent per request. For high-volume applications, this adds up, so tracking your token usage is essential.

The context window for our API is 100,000 tokens, which includes both the prompt and the completion. If your prompts are long, you will consume input tokens faster. However, the rate remains the same per million tokens. You can optimize your prompts to reduce input costs without affecting the quality of the output.

When you send a request, the API counts the tokens in the prompt. If the prompt exceeds the context window, the request may fail, but you will not be charged for the excess tokens. This protects your budget from unexpected overages. Always monitor your usage to ensure you stay within your budget.

Calculating Output Token Costs

Output tokens are the tokens generated by the model in response to your prompt. Our API charges $0.50 per one million output tokens. This rate is higher than the input rate because generating text requires more computational resources. You pay for the length of the response, so shorter responses cost less.

To estimate output costs, count the tokens in the generated text and multiply by $0.50 per million. For example, if a response contains 500 tokens, the cost is calculated by dividing 500 by 1,000,000 and then multiplying by $0.50. This helps you predict the cost of each interaction in your application.

Streaming responses allow you to receive tokens as they are generated. The API provides usage information in the last chunk of the stream, so you can track the total tokens used in real-time. This is useful for monitoring costs during long-running sessions. You can stop the stream early to save on output tokens if the response is sufficient.

Function calling and JSON mode also consume output tokens. When the model returns structured data, it is counted as part of the output. This means that complex responses with multiple tools or detailed JSON structures will cost more. Plan your responses to be concise to minimize output costs.

Worked Example for a Chat Application

Consider a chat application where users send short messages and receive concise replies. Suppose each user message averages 200 tokens, and the model generates an average of 300 tokens in response. To calculate the cost per interaction, we first determine the total tokens per request, which is 500 tokens.

The input cost is calculated by dividing 200 by 1,000,000 and multiplying by $0.15. The output cost is calculated by dividing 300 by 1,000,000 and multiplying by $0.50. Adding these together gives the total cost per interaction. This method allows you to estimate the cost for thousands of interactions without computing large dollar totals.

If your application handles 10,000 interactions per day, you can multiply the cost per interaction by 10,000 to get the daily cost. This helps you budget for your API usage over time. You can adjust the token counts based on your actual usage to get a more accurate estimate.

Remember that errors and refusals are free. If some requests fail, you save on those costs. This makes the API cost-effective for applications with variable success rates. Always test your application with real data to get the most accurate cost estimates.

When Our API Is Not the Right Choice

Our API is designed for text generation only. If you need image, audio, or video generation, our service is not the right choice. We do not support embeddings, OCR, or fine-tuning. If your application requires these features, you may need to use a different provider or combine our API with other tools.

Additionally, if you need a service with a guaranteed SLA or specific certifications like SOC2 or HIPAA, our API may not meet your needs. We do not claim these certifications, so if they are critical for your use case, you should consider other options. Our focus is on providing a simple, uncensored text API without complex enterprise features.

If you require model routing or the ability to switch between different models dynamically, our API does not support this. We serve one uncensored open-weight text model. If you need to experiment with multiple models, you may need to integrate multiple APIs or use a platform that supports model routing.

Finally, if you prefer to pay with credit cards or PayPal, our crypto-only payment method might not be suitable. We accept USDT on TRC20 or USDC on Base. If you need traditional payment methods, you may need to look elsewhere. Our service is ideal for developers who are comfortable with crypto payments and want a simple, uncensored text API.

Addressing Common Developer Questions

Developers often ask how to handle rate limits and errors when using our API. Our API allows 300 requests per minute per key. If you exceed this limit, you will receive a 429 error. To avoid this, you can implement retry logic with exponential backoff in your application. This ensures that you do not overwhelm the API during peak usage.

Another common question is how to manage tokens in long conversations. Our API supports a 100,000-token context window, which is quite large. However, if your conversation exceeds this limit, you may need to truncate older messages. This helps you stay within the context window while maintaining the flow of the conversation.

Users also ask about the difference between input and output tokens. Input tokens are the tokens you send, while output tokens are the tokens the model generates. Both are charged separately, with output tokens costing more. Understanding this distinction helps you budget for your API usage more accurately.

Finally, developers often wonder about the trial credit. Every new account gets $0.50 of trial credit, which is enough to test the API without paying. This allows you to verify that the API meets your needs before purchasing a top-up. It is a great way to start without any financial commitment.

Optimizing Your API Usage

To optimize your API usage, start by using the streaming feature. This allows you to receive tokens as they are generated, so you can stop the stream early if the response is sufficient. This can save on output tokens, especially for long responses. It also provides a better user experience by showing text as it is generated.

Use the JSON mode when you need structured data. This reduces the amount of text the model needs to generate, which can lower output costs. It also makes it easier to parse the response in your application. Function calling is another feature that can help you get structured data without extra text.

Monitor your token usage regularly. Our API provides usage information in the last chunk of the stream, so you can track your consumption in real-time. This helps you identify any unexpected costs and adjust your prompts or responses accordingly. You can also set up alerts for high usage to avoid unexpected charges.

Finally, consider using the seed parameter to get consistent responses. This is useful for testing and debugging. By setting a seed, you can reproduce the same response multiple times, which helps you verify that your prompts are working as expected. This reduces the need for multiple requests, saving on tokens.

Frequently asked questions

How do I calculate the cost of a request?

Divide the number of input tokens by 1,000,000 and multiply by $0.15. Do the same for output tokens using $0.50. Add the two values together to get the total cost.

What happens if my request fails?

Errors and refusals are free. You are not charged for tokens in failed requests, so you only pay for successful interactions.

Can I use a credit card to top up?

No, we only accept crypto. You can pay with USDT on TRC20 or USDC on Base, with amounts between $20 and $500.

How much trial credit do I get?

Every new account receives $0.50 of trial credit, which you can use to test the API without entering a credit card.