Login
Back to Blog
EnglishTutorial

How to Access GPT-5 and GPT-5.2 via API - Complete Developer Guide

Learn how to access OpenAI's latest GPT-5, GPT-5.2, and o3-pro models through a unified API. Step-by-step guide with Python, Node.js, and curl examples.

C
Crazyrouter Team
January 22, 2026 / 688 views
Share:
How to Access GPT-5 and GPT-5.2 via API - Complete Developer Guide

OpenAI has released its most powerful models yet: GPT-5, GPT-5.2, and the reasoning-focused o3-pro. This guide shows you how to access these cutting-edge models through Crazyrouter's unified API.

Supported OpenAI Models#

Crazyrouter provides access to the complete OpenAI model lineup:

ModelInput ($/1M tokens)Output ($/1M tokens)Best For
gpt-5.2$1.75$14.00Latest flagship, complex tasks
gpt-5.2-pro$3.50$28.00Enhanced reasoning
gpt-5$1.25$10.00General tasks
gpt-5-pro$2.50$20.00Advanced analysis
gpt-5-mini$0.25$2.00Cost-effective
gpt-5-nano$0.05$0.40High-volume tasks
o3-pro$20.00$80.00Complex reasoning
o3-mini$1.10$4.40Efficient reasoning
o4-mini$1.10$4.40Latest reasoning model

Quick Start#

1. Get Your API Key#

  1. Visit Crazyrouter Console
  2. Navigate to "Token Management"
  3. Click "Create Token"
  4. Copy your API key (starts with sk-)

2. Make Your First Request#

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-api-key",
    base_url="https://crazyrouter.com/v1",
    default_headers={
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
    }
)

response = client.chat.completions.create(
    model="gpt-5.2",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain quantum computing in simple terms."}
    ],
    temperature=0.7,
    max_tokens=1000
)

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

Using Node.js#

javascript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'sk-your-api-key',
  baseURL: 'https://crazyrouter.com/v1',
  defaultHeaders: {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
  }
});

async function main() {
  const response = await client.chat.completions.create({
    model: 'gpt-5.2',
    messages: [
      { role: 'system', content: 'You are a helpful assistant.' },
      { role: 'user', content: 'Explain quantum computing in simple terms.' }
    ],
    temperature: 0.7
  });

  console.log(response.choices[0].message.content);
}

main();

Using curl#

bash
curl https://crazyrouter.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \
  -d '{
    "model": "gpt-5.2",
    "messages": [{"role": "user", "content": "Hello, GPT-5.2!"}],
    "temperature": 0.7
  }'

Streaming Responses#

For real-time output, enable streaming:

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-api-key",
    base_url="https://crazyrouter.com/v1",
    default_headers={
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
    }
)

stream = client.chat.completions.create(
    model="gpt-5.2",
    messages=[{"role": "user", "content": "Write a short story about AI."}],
    stream=True
)

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

Using Reasoning Models (o3-pro)#

The o3-pro model excels at complex reasoning tasks:

python
response = client.chat.completions.create(
    model="o3-pro",
    messages=[
        {"role": "user", "content": "Solve this step by step: If a train travels 120 miles in 2 hours, then stops for 30 minutes, then travels another 90 miles in 1.5 hours, what is the average speed for the entire journey including the stop?"}
    ]
)

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

GPT-5 Codex Models#

For code generation tasks, use the specialized codex models:

python
response = client.chat.completions.create(
    model="gpt-5-codex",
    messages=[
        {"role": "user", "content": "Write a Python function to implement binary search"}
    ]
)

Available codex variants: gpt-5-codex, gpt-5-codex-high, gpt-5-codex-medium, gpt-5-codex-low, gpt-5.2-codex

Best Practices#

  1. Choose the right model: Use gpt-5-nano for simple tasks, gpt-5.2 for complex ones
  2. Set appropriate temperature: Lower (0.1-0.3) for factual tasks, higher (0.7-1.0) for creative tasks
  3. Use streaming: For better user experience in chat applications
  4. Handle errors gracefully: Implement retry logic for rate limits

Next Steps#


For questions, contact support@crazyrouter.com

Implementation Guides

Related Posts

Qwen2.5-Omni Complete Guide: Alibaba's Multimodal AI Model for DevelopersTutorial

Qwen2.5-Omni Complete Guide: Alibaba's Multimodal AI Model for Developers

"Complete developer guide to Qwen2.5-Omni — Alibaba's multimodal AI model that processes text, images, audio, and video. Includes API setup, code examples, and pricing."

Feb 19
Best AI Assistants for Telegram, WhatsApp & Discord in 2026Tutorial

Best AI Assistants for Telegram, WhatsApp & Discord in 2026

Looking for an AI assistant that works across your favorite messaging apps? Whether you want to chat with Claude on Telegram, use GPT-4 through WhatsApp

Jan 26
Google Veo3 API Guide: Generate AI Videos with Audio in 2026Tutorial

Google Veo3 API Guide: Generate AI Videos with Audio in 2026

"Complete guide to using Google Veo3 API for AI video generation with native audio. Includes setup, code examples, pricing, and comparison with Sora and Kling."

Feb 19
Pika 2.2 API Integration Guide: Build Video Generation Pipelines in 2026Tutorial

Pika 2.2 API Integration Guide: Build Video Generation Pipelines in 2026

"Step-by-step guide to integrating Pika 2.2's API into production video pipelines. Covers text-to-video, image-to-video, effects, pricing, and multi-model fallback strategies."

Apr 13
OpenAI-Compatible API Base URL Explained: How to Configure Any AI ToolTutorial

OpenAI-Compatible API Base URL Explained: How to Configure Any AI Tool

Learn what an OpenAI-compatible API Base URL is, how to configure it in Python, Node.js, curl, Cursor, LiteLLM, FastGPT, Codex-style tools, and how to avoid common mistakes like missing /v1 or using the wrong endpoint.

Jun 4
Codex CLI Installation Guide: Setup on macOS, Linux, Windows WSL and CI/CDTutorial

Codex CLI Installation Guide: Setup on macOS, Linux, Windows WSL and CI/CD

"Step-by-step Codex CLI installation guide for macOS, Linux, Windows WSL, Docker, and CI/CD pipelines. Includes proxy configuration, troubleshooting, and team onboarding."

May 5