Quick Start

Get Started in 5 Minutes

Follow these three steps to start making API requests through API Key Hub. No new libraries required -- use the standard OpenAI SDK you already know.

1

Sign Up and Get Your API Key

  1. Create an account on API Key Hub (you get $2.00 in free credits).
  2. Go to your Dashboard → API Keys page.
  3. Click "Create Key" and choose a plan that fits your needs.
  4. Copy your API key immediately -- it is shown only once. It starts with sk-.

Important: Store your API key securely. Do not commit it to version control or expose it in client-side code. Use environment variables instead.

2

Install the SDK

API Key Hub is fully compatible with the official OpenAI SDK. Install it for your language of choice:

Python
pip install openai

Set your API key as an environment variable:

Shell
export APIKEYHUB_API_KEY="sk-your-api-key"
3

Make Your First Request

The only difference from using OpenAI directly is the base_url. Everything else stays exactly the same:

Python
from openai import OpenAI

client = OpenAI(
    base_url="https://xylove.net/v1",
    api_key="sk-your-api-key"
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello! What can you do?"}
    ],
    temperature=0.7,
    max_tokens=256
)

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

Streaming Responses

Streaming is fully supported. Add stream=True to get tokens as they are generated:

Python
from openai import OpenAI

client = OpenAI(
    base_url="https://xylove.net/v1",
    api_key="sk-your-api-key"
)

stream = client.chat.completions.create(
    model="claude-sonnet-4-6",
    messages=[{"role": "user", "content": "Write a haiku about coding"}],
    stream=True
)

for chunk in stream:
    content = chunk.choices[0].delta.content
    if content:
        print(content, end="", flush=True)

Available Models

You can use any model available on API Key Hub. Popular options include:

ModelProviderBest For
gpt-4oOpenAIGeneral purpose, fast
gpt-4o-miniOpenAICost-effective tasks
claude-sonnet-4-6AnthropicCoding, analysis
gemini-2.5-proGoogleLong context, multimodal
deepseek-chatDeepSeekBudget-friendly reasoning

See the full list by calling the GET /v1/models endpoint or visiting our pricing page.

Next Steps

  • API Reference -- Explore all available endpoints and parameters.
  • Error Handling -- Learn how to handle errors and rate limits gracefully.
  • Migration Guide -- Moving from OpenAI or Anthropic direct APIs? Follow our migration guide.
  • API Playground -- Try the API interactively from your browser.