Integrating OpenRouter API: A Developer Checklist
Connecting your application to an uncensored text model requires precise configuration and a clear understanding of the endpoint structure. This guide walks you through the exact steps to integrate the API, manage token costs, and handle streaming responses effectively.

Understanding the API Endpoint Structure
Before writing any code, you must identify the correct base URL and model identifier for your integration. The service provides a hosted, OpenAI-compatible chat-completions API that serves a single uncensored open-weight text model. This simplifies the integration process because you do not need to manage multiple model versions or routing logic. The base URL for all requests is https://api.openrouterdolphin.com/v1, which you should configure in your application's environment variables.
The model identifier you must send in your requests is simply "uncensored". This string tells the system to use the specific uncensored model available on this service. Unlike other platforms that offer a directory of models, this endpoint serves only one model, ensuring consistent behavior across all requests. You will send text in and receive text out, with no additional parameters needed to select the model itself.
It is important to note that this service does not offer embeddings, image generation, audio processing, or video generation. It is strictly a text-in, text-out API. If your application requires multimodal capabilities, you will need to integrate separate services for those tasks. For now, focus on the text completion workflow, which is optimized for high-volume text generation tasks.
When setting up your initial connection, ensure that your HTTP client is configured to handle JSON payloads correctly. The API expects standard JSON structures for requests and returns JSON for responses. This compatibility with OpenAI-compatible formats means that many existing libraries and SDKs can be used with minimal modification. Verify your connection by sending a simple test request to the /v1/models endpoint, which confirms the API is reachable and the model is available.
Configuring Authentication and Keys
Authentication is handled via API keys, which you generate during the signup process. You can sign up using Google or an email and password combination. Upon creation, your API key is shown immediately, so you must copy it securely before leaving the page. This key is the primary credential for authenticating your requests to the API. Store it in a secure environment variable or secret manager in your application to prevent accidental exposure in version control systems.
Each API key is subject to a rate limit of 300 requests per minute. This limit applies per key, so if you have multiple keys, you can distribute the load across them. However, for most individual developers and small teams, a single key is sufficient. Monitor your usage to ensure you do not exceed this limit, as hitting the rate limit will result in a 429 error. You can implement exponential backoff in your application to handle these errors gracefully.
Errors during authentication are indicated by specific HTTP status codes. A 401 error means your API key is invalid or missing. A 402 error indicates that you have no remaining prepaid credit. A 429 error signals that you have exceeded the rate limit. Handle these errors explicitly in your code to provide better feedback to your users. For example, if you receive a 402 error, prompt the user to top up their credit via crypto.
Remember that the key is shown only once upon creation. If you lose it, you may need to generate a new one, depending on the platform's key management features. Keep your keys private and do not share them in public repositories. Use environment variables to inject the key into your application at runtime. This ensures that your credentials are secure and easy to rotate if necessary.
Setting Up Streaming Responses
Streaming responses allow you to receive text chunks as they are generated, providing a better user experience for long-form content. The API supports streaming over Server-Sent Events (SSE), which is a standard protocol for sending real-time updates from the server to the client. To enable streaming, you set the stream parameter to true in your request. The server will then send a series of text chunks, each containing a portion of the generated text.
Each streaming response includes a final chunk that contains the usage data, such as the number of tokens consumed. This allows you to track costs in real-time as the response is generated. The usage data is included in the last chunk of the stream, so you must wait for the stream to complete to get the total token count. This is useful for budgeting and monitoring your API usage.
Implementing streaming requires handling the SSE protocol correctly. Your client should listen for incoming events and process the text chunks as they arrive. You can append these chunks to a buffer or display them directly to the user. Ensure that your application can handle partial responses and reconnect if the stream is interrupted. This is particularly important for applications that generate long texts, where network issues may occur.
Streaming is ideal for chat interfaces, code generation tools, and real-time text analysis. It reduces the perceived latency for users, as they see text appear as it is generated. However, it requires more complex client-side logic compared to standard synchronous requests. Test your streaming implementation thoroughly to ensure that text is displayed correctly and that usage data is accurately captured. This approach aligns well with the uncensored nature of the model, allowing for continuous, unbroken text generation.
Managing Token Costs and Budgeting
Understanding the pricing model is important for budgeting your API usage. The service charges $0.15 per million input tokens and $0.50 per million output tokens. This pricing structure is based on actual token usage, meaning you only pay for the tokens consumed in your requests. Errors and refusals are free, so you do not incur costs for failed requests or content that is refused due to the hard content limit.
To estimate costs, you can use the formula: (tokens divided by 1,000,000) times the per-million price. For example, if a request consumes 500,000 input tokens and 100,000 output tokens, the cost would be calculated as follows: (500,000 / 1,000,000) * $0.15 for input, and (100,000 / 1,000,000) * $0.50 for output. This allows you to predict costs based on expected token usage. Monitor your usage regularly to ensure you stay within your budget.
Prepaid credit is charged by real token usage, and there is no monthly fee or subscription. Paid credit never expires, so you can top up whenever you need. The top-up process is crypto-only, accepting USDT on TRC20 or USDC on Base. You can top up any whole amount from $20 to $500. If you top up $50 or more, you may receive bonus credit ranging from +5% to +15%, depending on the amount.
Since there is no card or PayPal option, ensure that you have a crypto wallet set up to manage your payments. The trial credit of $0.50 is available for new accounts without a card, allowing you to test the API before committing to a purchase. Use this trial to verify your integration and estimate token usage for your specific use case. This helps you avoid unexpected costs when you start using the API at scale.
Handling Parameters and Configuration
The API supports several parameters to customize the behavior of the model, including temperature, top_p, stop sequences, seed, and penalties. These parameters allow you to control the creativity, randomness, and stopping conditions of the generated text. For example, setting a lower temperature value will result in more deterministic and focused outputs, while a higher value will introduce more randomness and creativity. Adjust these parameters based on your specific use case.
The top_p parameter controls the nucleus sampling, which limits the vocabulary to the most likely tokens. This can help reduce the likelihood of generating nonsensical or off-topic text. The stop parameter allows you to specify sequences that will terminate the generation, which is useful for controlling the length of the output or stopping at specific markers. Use these parameters to fine-tune the model's behavior for your application.
The seed parameter allows you to set a random seed for reproducibility. This is useful for debugging and testing, as it ensures that the same input produces the same output. Penalties can be used to discourage certain tokens or patterns in the output. These features provide fine-grained control over the model's generation process, allowing you to optimize for quality and consistency.
Function calling and JSON mode are also supported, enabling you to integrate the API with structured data workflows. Function calling allows the model to generate structured data that can be parsed and used by your application. JSON mode ensures that the output is valid JSON, which is useful for APIs that expect structured responses. Test these features thoroughly to ensure they work correctly with your application's data structures.
When This API Is Not the Right Choice
While this API is excellent for uncensored text generation, it may not be the right choice for all applications. If your application requires image, audio, or video generation, you will need to integrate separate services, as this API is text-only. Similarly, if you need embeddings for semantic search or fine-tuning for custom model behavior, this service does not offer those features. Consider these limitations when designing your architecture.
If you require a service with an SLA guarantee, such as 99.9% uptime, this API does not provide such guarantees. It is an independent service without certified uptime SLAs. If your application is mission-critical and requires high availability, you may need to implement redundancy or choose a provider with stronger SLA commitments. Similarly, if you need on-premises deployment for data sovereignty, this hosted service may not meet your requirements.
The uncensored nature of the model means that it does not refuse lawful adult, fictional, or controversial topics. If your application requires strict content filtering for a younger audience, you may need to implement additional filtering logic on top of the API. The hard content limit only refuses sexual content involving minors, so other types of content may be generated. Evaluate whether the model's behavior aligns with your application's content policy.
If you need benchmark scores or named customers to validate the model's performance, this service does not provide such data. It is an independent service focused on providing uncensored text generation. If you require proven benchmark performance or enterprise-level support, you may need to consider other providers. Use this API for projects where uncensored text generation is the primary requirement and other features are secondary.
Troubleshooting Common Issues
Developers often encounter issues with rate limits and authentication errors when integrating with the API. A 429 error indicates that you have exceeded the 300 requests per minute limit. To resolve this, implement exponential backoff in your application to retry requests after a delay. You can also distribute requests across multiple API keys if you have them. Monitor your usage to ensure you do not consistently hit the rate limit.
A 401 error means your API key is invalid or missing. Check that you are sending the correct key in the Authorization header. A 402 error indicates that you have no remaining prepaid credit. In this case, you need to top up your account using crypto. Ensure that your application handles these errors gracefully and provides feedback to the user. For example, display a message prompting the user to top up their credit.
Another common issue is handling streaming responses correctly. Ensure that your client is configured to handle SSE events and that you are processing the text chunks as they arrive. If the stream is interrupted, implement logic to reconnect or retry the request. This is particularly important for long-form text generation, where network issues may occur. Test your streaming implementation thoroughly to ensure reliability.
If you are using function calling or JSON mode, ensure that your application can parse the structured output correctly. Validate the JSON response before using it in your application. If the model generates invalid JSON, implement a retry mechanism or a fallback strategy. These troubleshooting steps will help you build a reliable integration that handles errors and edge cases effectively.
Frequently asked questions
How do I top up my credit?
You can top up your credit using crypto only, specifically USDT on TRC20 or USDC on Base. The minimum amount is $20 and the maximum is $500 per transaction. If you top up $50 or more, you may receive bonus credit ranging from +5% to +15%. Cards and PayPal are not accepted.
What is the context window size?
The context window is 100,000 tokens, which includes both the prompt and the completion together. This allows for long-context applications and detailed text generation. Ensure that your input and output tokens stay within this limit to avoid truncation.
Is there a free trial?
Yes, every new account receives $0.50 of trial credit without needing a credit card. This allows you to test the API and verify your integration before purchasing prepaid credit. The trial credit can be used for any request, including streaming and function calling.
Does the API support image generation?
No, this API is strictly text-in, text-out. It does not support image, audio, video, or embedding generation. If you need multimodal capabilities, you will need to integrate separate services for those tasks. Focus on text generation workflows for this API.