Skip to main content
Get started with YouRouter The YouRouter API provides OpenAI-compatible endpoints that give you access to advanced language models. Get started with just a few lines of code using your preferred SDK or framework.
Looking for your API key? Get it from the YouRouter Dashboard.

Using the OpenAI SDK

The easiest way to get started is with the official OpenAI SDKs. Simply set the base URL to the YouRouter API endpoint.
  • Python
  • Node.js
from openai import OpenAI

client = OpenAI(
    base_url="https://api.yourouter.ai/v1",
    api_key="<YOUR_YOUROUTER_API_KEY>",
)

completion = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {
            "role": "user",
            "content": "What is the meaning of life?"
        }
    ]
)

print(completion.choices[0].message.content)

Generate text with responses (OpenAI only)

The responses endpoint lets you request a single text completion. This method is currently available only via the OpenAI SDK.
from openai import OpenAI
client = OpenAI(
    base_url="https://api.yourouter.ai/v1",
    api_key="<YOUR_YOUROUTER_API_KEY>",
)

response = client.responses.create(
    model="gpt-4.1",
    input="Write a one-sentence bedtime story about a unicorn."
)

print(response.output_text)

Using the YouRouter API directly

You can also make direct HTTP requests to the YouRouter API using any HTTP client.
  • cURL
  • Python (requests)
  • JavaScript (fetch)
curl https://api.yourouter.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <YOUR_YOUROUTER_API_KEY>" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "user",
        "content": "What is the meaning of life?"
      }
    ]
  }'
The API also supports streaming responses for real-time applications.

Environment Setup

For production applications, we recommend storing your API key as an environment variable:
  • macOS/Linux
  • Windows
  • Python (.env)
export YOUROUTER_API_KEY="your-api-key-here"

Billing and Our Refund Promise

YouRouter operates on a prepaid balance model, giving you full control over your spending.

Our Commitment to Your Flexibility

We understand that plans can change. That’s why we offer a straightforward and hassle-free refund policy. Your unused balance is always yours. If you decide to stop using our service for any reason, you can request a full refund of your remaining balance directly through the platform. We’ll process it back to your original payment method, no questions asked. Our goal is to give you the confidence and peace of mind to innovate without risk. For more details, see the Rate Limits & Refunds guide and our Zero Completion Insurance policy.

Next Steps

Need help? Check out our API Reference for detailed documentation.
I