- Python (OpenAI SDK)
- JavaScript (OpenAI SDK)
- cURL
The examples use documented NexLLM model identifiers. Before sending a request, confirm that the selected model is available to your API key through the Models endpoint.
Prerequisites
1
A NexLLM account with an active API key
Sign in to the NexLLM dashboard and create an API key.Review the key’s channel group, model restrictions, expiration, quota, and IP allowlist.See API Keys for setup instructions.
2
Available account balance
Check your account balance before testing billable requests.See Wallet for funding instructions.
3
An existing OpenRouter integration
This guide is for applications already using OpenRouter through the OpenAI SDK or an HTTP client.If you are starting a new integration, follow the Quickstart instead.
Quick Start for Claude Code Users
If you use Claude Code to edit your application, give it the following migration instructions. This is a prompt for updating your project, not a downloadable skill or a command that changes Claude Code’s own model provider.Step 1: Update Your Environment Variables
Replace your OpenRouter configuration with NexLLM credentials and connection settings.Step 2: Update Your Client
Configure your client with the NexLLM base URL and API key.- Python (OpenAI SDK)
- JavaScript (OpenAI SDK)
- cURL
Remove OpenRouter Attribution Headers
Remove OpenRouter-specific attribution headers from the NexLLM client:HTTP-RefererX-OpenRouter-TitleX-Title, if present in an older integration
Review Routing and Other Extensions
Do not forward OpenRouter-specific options without checking their replacement behavior. Review:- The
providerobject and provider preferences. - The
modelsarray used for model fallbacks. - Automatic model selection.
- Plugins and request transformations.
- Provider-specific privacy or retention controls.
Step 3: Update Model Identifiers
Use the exact model IDs returned by NexLLM. Examples documented by NexLLM include:
For example, an OpenRouter request using
openai/gpt-4o should use NexLLM’s documented gpt-4o identifier, provided it is available to your key.
Do not apply a blanket rule that removes or replaces every prefix. Some NexLLM identifiers contain a prefix, as shown by aws/claude-haiku-4-5.
List Models Available to Your Key
- cURL
- Python
id exactly.
See the Models API.
Review Auto-Routing Separately
If your existing application usesopenrouter/auto, do not automatically rename it to auto.
Select an explicit NexLLM model for initial testing, and verify any automatic selection requirements separately.
Check Your Channel Group
Each NexLLM API key belongs to one channel group. That group determines model access and the pricing multiplier applied to usage. Before deployment:- Check the group assigned to the production key.
- Confirm that it includes the intended models.
- Review its pricing and connectivity characteristics.
- Verify any additional key-level model restrictions.
Step 4 (Optional): Adopt the Responses API
You can keep using Chat Completions after migrating. If your application needs the OpenAI Responses format, NexLLM also documents:NEXLLM_MODEL is set to a model that supports Responses.
- cURL
- Python
- JavaScript
Responses uses a different request and response shape from Chat Completions. Update your response parsing and test the specific features your application requires rather than changing only the endpoint.
Why Migrate to NexLLM
Keep Your OpenAI-Compatible Client
Use NexLLM’s Chat Completions endpoint with your existing OpenAI SDK. For a basic integration, the main changes are the base URL, credential, and model ID. Review provider-specific extensions separately.Access GPT, Claude, and Gemini
Use a single API integration for multiple model families, subject to your key’s permissions and channel group. Explore:Choose Model Access and Pricing Through Channel Groups
Select a channel group that matches your model requirements and preferred pricing. The group ratio adjusts the model’s base usage cost:Configure Access Controls Per Key
Create separate keys for different projects or environments. NexLLM documents configurable expiration, quota limits, model restrictions, and IP allowlists. See API Keys.Review Requests and Usage
Use NexLLM’s usage logs to inspect request timing, key names, models, token consumption, and cost. The dashboard provides aggregate request, token, and quota statistics. See Usage & Logs.Choose an API Format That Fits Your Application
Alongside Chat Completions, NexLLM documents Responses and Claude-native Messages endpoints. Check endpoint compatibility for your chosen model before changing formats. See the API Reference.Troubleshooting
Invalid API key or authentication failure
Invalid API key or authentication failure
Confirm that See Authentication.
NEXLLM_API_KEY contains your NexLLM credential, not the old OpenRouter key.Check for extra whitespace, stale deployment secrets, expiration, and IP allowlist restrictions.Standard OpenAI-compatible requests use:Connection errors or incorrect endpoint
Connection errors or incorrect endpoint
Confirm that the SDK base URL is:Do not retain OpenRouter’s A successful model-list request does not replace testing an actual completion request.
/api/v1 path or append /v1 twice.Test authentication and connectivity with:Insufficient balance or exhausted quota
Insufficient balance or exhausted quota
An optional parameter or advanced feature fails
An optional parameter or advanced feature fails
Reduce the request to a supported model and a short messages array.Reintroduce optional fields one at a time, checking the chosen model’s endpoint compatibility.Pay particular attention to OpenRouter-specific routing fields, plugins, and fallback settings.Test streaming, tools, structured outputs, and multimodal inputs separately if your application uses them.
Usage or costs differ from the previous integration
Usage or costs differ from the previous integration
Check the requested model, actual token usage, and the pricing ratio for your key’s channel group.Review any applicable cache or multimodal charges.Use NexLLM’s pricing information rather than carrying over OpenRouter-specific accounting assumptions.See Pricing and Usage & Logs.
Verify Before Production
Use this checklist before completing the migration:- Replace the base URL and API key.
- Confirm model IDs using the production key.
- Review the key’s channel group and restrictions.
- Remove OpenRouter attribution headers.
- Review routing, fallbacks, and provider-specific fields.
- Verify required privacy and retention controls.
- Test representative prompts and conversation history.
- Test streaming and other advanced features where used.
- Check error handling, timeouts, and retries.
- Review usage logs and expected costs.
- Keep a tested rollback configuration during rollout.
Next Steps
API Reference
Explore supported endpoints and request formats.
Available Models
Find exact model IDs available to your API key.
Channel Groups
Understand model access and group pricing.
Usage & Logs
Inspect requests and monitor usage after migration.
Feedback
When reporting a migration issue to the NexLLM team, include:- Your SDK and version.
- The endpoint and model ID.
- The HTTP status and sanitized error message.
- The approximate request time.
- A request identifier, if available.
- A minimal reproduction with sensitive content removed.