EN ▾
Get your key

Estimating API Costs for Mistralllmapi Projects

Developers often ask how to budget for token usage when integrating a text API. This article teaches a method to estimate costs using Mistralllmapi's pricing structure, with a worked example to help you plan your budget effectively.

Developer workspace with crypto coins and chat interface for API cost estimation

Understanding the Token-Based Pricing Model

When integrating a hosted text API, the first step is understanding how billing works. Our service uses a prepaid credit system based on real token usage. This means you pay only for what you use, with no monthly subscription fees or hidden charges. The model id to send is simply uncensored, and the API serves text in and text out through standard endpoints.

The pricing structure is straightforward: we charge $0.15 per one million input tokens and $0.50 per one million output tokens. This dual pricing reflects the different computational costs of processing your prompt versus generating the response. By separating these costs, you can better predict expenses based on the complexity of your prompts and the length of the generated text.

It is important to note that errors and refusals are free. If your request fails due to an invalid key or a rate limit, you are not charged. Similarly, if the model refuses a request due to our hard content limit regarding sexual content involving minors, that token usage does not count against your balance. This safety feature ensures you do not pay for content that does not meet our policy standards.

Because the system is prepaid, your credit never expires. This allows you to top up whenever convenient without worrying about losing unused funds. The lack of a monthly fee means your costs scale directly with your usage, making it ideal for projects with variable traffic patterns. You only pay for the tokens you actually consume during your API calls.

Calculating Input and Output Costs

To estimate your budget, you need to understand how tokens are counted. The context window for our API is 100,000 tokens, which includes both the prompt and the completion together. This large window allows for extensive context handling, which is important for complex applications. However, it also means you need to be mindful of how much text you send in a single request.

Input tokens are the words you send to the API. The cost is $0.15 per million tokens. For example, if your prompt is very long, this cost will increase. Output tokens are the words the model generates. The cost is $0.50 per million tokens. Since generation is more computationally intensive, the price is higher. You should estimate the average length of your responses to calculate this part of the cost.

When building your budget, consider the ratio of input to output tokens. Some tasks require long prompts but short responses, while others might generate lengthy explanations. By tracking these ratios in your development phase, you can create a more accurate cost model. This helps in planning for peak usage periods without overspending.

Remember that the formula for cost is the number of tokens divided by one million, multiplied by the per-million price. This simple calculation allows you to predict expenses for any given volume of requests. It also helps in comparing different strategies for prompt engineering to see if shorter prompts can reduce costs without sacrificing quality.

Managing Credit and Top-Ups

Our API requires payment via cryptocurrency only. You can top up using USDT on the TRC20 network or USDC on the Base network. The minimum top-up amount is $20, and the maximum is $500. This restriction means you cannot use credit cards, PayPal, or bank transfers. It is important to have a crypto wallet ready before you start using the API for production work.

When you top up, you may receive bonus credit. If you top up from $50, you get between 5% and 15% bonus credit. This bonus helps you get more value for your money. However, the bonus is tied to the top-up amount, so smaller top-ups do not trigger this benefit. You should consider the size of your top-ups to maximize these bonuses.

The key is shown immediately after signup, which allows you to start testing right away. You do not need to wait for payment confirmation to begin using the trial credit. This immediate access is useful for developers who want to integrate the API quickly. You can start making requests while you arrange your crypto payment.

Since errors are free, you can test your integration extensively without worrying about depleting your credit. This is a significant advantage for developers who need to debug their code. You can send multiple requests to test different scenarios and ensure your application handles responses correctly before committing to a larger top-up.

Using Trial Credit for Initial Testing

Every new account receives $0.50 of trial credit. This allows you to test the API without any financial commitment. No card is needed to sign up, which makes it easy to get started. You can use this trial credit to explore the endpoints and understand how the model responds to different prompts.

The trial credit is a great way to verify that your integration works correctly. You can send requests to the /v1/chat/completions endpoint and check the responses. This helps you ensure that your code handles the API correctly before you invest in a larger top-up. It also allows you to test the streaming feature and function calling capabilities.

Since the trial credit is limited, you should use it wisely. Focus on testing the core functionality of your application. Check that you can handle errors like 401 invalid key or 402 no credit. This preparation will save you time and money when you move to production. You can also test the rate limit of 300 requests per minute to see how your application performs under load.

Once you have exhausted the trial credit, you will need to top up to continue using the API. The transition from trial to paid usage is smooth. You can top up using crypto and immediately start making requests. The prepaid credit system ensures that you always know how much you have left, which helps in managing your budget effectively.

When This API Is Not the Right Choice

While our API is excellent for text generation, it is not suitable for all use cases. We do not offer embeddings, image generation, audio or video generation, OCR, or fine-tuning. If your project requires these features, our API will not be the right choice. You would need to look for a different service that supports these capabilities.

For example, if you need to convert images to text, our API cannot handle OCR. You would need to use a separate tool for this task. Similarly, if you need to generate images from text, you would need a different model. Our API focuses solely on text-to-text interactions, so you must plan your architecture accordingly.

Additionally, if you need a model with specific benchmark scores or 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 industry, you should verify this with your compliance team. Our focus is on providing an uncensored text model for developers who need flexibility in their content generation.

Finally, if you need on-prem deployment, our hosted service might not fit your infrastructure requirements. We offer a hosted solution, so you do not have control over the physical servers. If data privacy and local processing are your top priorities, you might prefer a self-hosted model. However, for most developers needing a reliable text API, our service is a strong option.

Integrating with Standard Tools

Our API is OpenAI-compatible, which means you can use standard tools and SDKs to integrate it into your projects. You can use the same code structure you would use for OpenAI, but point it to our base URL. This compatibility reduces the learning curve and allows you to use existing libraries and frameworks.

You can use the /v1/chat/completions endpoint for standard chat interactions. The API supports streaming over SSE, which allows you to receive responses in real-time. This is useful for applications where you want to display text as it is generated. You can also use function calling and JSON mode to integrate the API with your application logic.

The parameters available include temperature, top_p, stop, seed, and penalties. These allow you to fine-tune the model's behavior. For example, you can set the temperature to control the randomness of the output. The seed parameter allows you to reproduce specific responses, which is useful for testing and debugging. These features give you control over the model's output.

Since the API is compatible with standard tools, you can easily switch between different providers if needed. This flexibility is valuable for developers who want to avoid vendor lock-in. You can test our API alongside other providers to see which one best fits your needs. The standard interface makes this comparison straightforward.

Troubleshooting Common Issues

When using the API, you may encounter errors such as 401 invalid key or 402 no credit. A 401 error means your API key is invalid or missing. You can check your key in the dashboard after signup. A 402 error means you have run out of credit. You can top up using crypto to resolve this.

Rate limits are also a common issue. The API allows 300 requests per minute per key. If you exceed this limit, you will receive a 429 error. You can handle this by implementing retry logic in your application. This ensures that your application can recover from temporary rate limits without failing.

Errors and refusals are free, so you do not need to worry about being charged for failed requests. This is useful for testing your application's error handling. You can simulate different error conditions to ensure your application behaves correctly. This helps in building a reliable application that can handle various scenarios.

Finally, remember that the model refuses requests involving sexual content with minors. This is a hard limit, so you need to ensure your prompts comply with this rule. If you send a request that violates this rule, it will be refused without charging your credit. This helps in maintaining the quality of the content generated by the API.

Frequently asked questions

How do I top up my credit?

You can top up using USDT on TRC20 or USDC on Base. The minimum amount is $20 and the maximum is $500. Credit never expires.

What happens if I get an error?

Errors like 401 or 429 are free. You are not charged for tokens in failed requests. This allows you to test your integration without cost.

Can I use a credit card?

No, we only accept crypto. You cannot use credit cards, PayPal, or bank transfers. You must use USDT or USDC.

Is there a free trial?

Yes, every new account gets $0.50 in trial credit. No card is needed to sign up and start testing.