Login
Back to Blog
EnglishTutorial

AI API Gateway for Thai Developers: Use GPT, Claude and Gemini with One Key

A practical guide for developers in Thailand who want one OpenAI-compatible endpoint for GPT, Claude and Gemini model calls.

C
Crazyrouter Team
May 22, 2026 / 324 views
Share:
AI API Gateway for Thai Developers: Use GPT, Claude and Gemini with One Key

AI API Gateway for Thai Developers: Use GPT, Claude and Gemini with One Key#

If you are building AI products in Thailand, you may need to test several model providers before choosing the right one. GPT may work well for one workflow, Claude may be better for long-form reasoning, and Gemini may be useful for fast or multimodal tasks.

The hard part is not only model quality. It is also operational complexity: different API keys, SDKs, response formats, billing dashboards and fallback logic.

An AI API gateway helps reduce that complexity. With Crazyrouter, you can use one API key and one OpenAI-compatible endpoint, then switch models by changing the model value.

This tutorial shows a simple setup you can use in a backend service, internal tool or prototype.

Why use one gateway?#

For many teams, the goal is not to lock into one model immediately. The goal is to compare models safely while keeping the application code stable.

A single gateway is useful when you want to:

  • Test GPT, Claude and Gemini in the same product flow.
  • Keep using OpenAI-compatible SDKs.
  • Reduce secrets management across environments.
  • Add fallback models later without rewriting the app.
  • Track model usage from one integration layer.

1. Get an API key#

Start with the documentation intro and quickstart:

Store your key as an environment variable:

bash
export CRAZYROUTER_API_KEY="cr_..."

For production, put the key in your hosting provider's secret manager. Do not expose it in browser-side code.

2. Configure the OpenAI-compatible client#

In a Node.js project, install the OpenAI SDK:

bash
npm install openai

Then set the baseURL to Crazyrouter:

js
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.CRAZYROUTER_API_KEY,
  baseURL: "https://crazyrouter.com/v1",
});

const completion = await client.chat.completions.create({
  model: "openai/gpt-4o-mini",
  messages: [
    { role: "system", content: "You are a concise technical assistant." },
    { role: "user", content: "Explain why an AI API gateway is useful." },
  ],
});

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

This is the main integration pattern: one key, one endpoint, familiar request structure.

3. Try GPT, Claude and Gemini#

To compare models, keep the same prompt and change only model:

js
const prompt = "Write a short support reply for a delayed delivery order.";

const modelIds = [
  "openai/gpt-4o-mini",
  "anthropic/claude-3-5-haiku",
  "google/gemini-1.5-flash",
];

for (const model of modelIds) {
  const result = await client.chat.completions.create({
    model,
    messages: [{ role: "user", content: prompt }],
  });

  console.log(`\n--- ${model} ---`);
  console.log(result.choices[0].message.content);
}

This makes it easier to evaluate tone, speed and output quality with real application prompts.

4. Python example#

The same approach works in Python:

python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["CRAZYROUTER_API_KEY"],
    base_url="https://crazyrouter.com/v1",
)

response = client.chat.completions.create(
    model="google/gemini-1.5-flash",
    messages=[
        {"role": "system", "content": "You help developers debug backend services."},
        {"role": "user", "content": "List three ways to reduce LLM API latency."},
    ],
)

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

5. Production checklist#

Before you connect this to a customer-facing workflow, add basic reliability controls:

  • Timeouts for every request.
  • Retry with exponential backoff for temporary failures.
  • Model-level logging for latency, token usage and errors.
  • Fallback rules for non-critical tasks if a provider is temporarily unavailable.

A simple fallback pattern can look like this:

js
async function completeWithFallback(messages) {
  const models = ["openai/gpt-4o-mini", "anthropic/claude-3-5-haiku"];

  for (const model of models) {
    try {
      return await client.chat.completions.create({ model, messages });
    } catch (error) {
      console.warn(`Model failed: ${model}`, error.message);
    }
  }

  throw new Error("All model attempts failed");
}

Next step#

Pick one low-risk workflow first: summarising support tickets, drafting product copy, classifying leads or generating internal reports. Run the same prompts through two or three models and compare results.

When you are ready to wire the full setup, follow the Crazyrouter quickstart.

Implementation Guides

Topics

Tutorial

Related Posts

AI API Gateway for Singapore and Malaysia Developers: One Endpoint for GPT, Claude and GeminiTutorial

AI API Gateway for Singapore and Malaysia Developers: One Endpoint for GPT, Claude and Gemini

A practical setup guide for Singapore and Malaysia developers who want one OpenAI-compatible endpoint for GPT, Claude and Gemini.

May 22
Seedream 4.0 API Tutorial: ByteDance's Image Generation Model for DevelopersTutorial

Seedream 4.0 API Tutorial: ByteDance's Image Generation Model for Developers

"Step-by-step tutorial for using Seedream 4.0 API — ByteDance's advanced image generation model. Includes setup, code examples, pricing, and comparison with DALL-E 3 and Midjourney."

Feb 19
DeepSeek V3.2 API Guide: How to Use China's Top Open-Source ModelTutorial

DeepSeek V3.2 API Guide: How to Use China's Top Open-Source Model

"Complete guide to DeepSeek V3.2 API — setup, code examples, pricing, and how it compares to GPT-4 and Claude for developers building AI applications."

Feb 21
How to Get a Claude API Key in 2026: Official Setup, Alternatives, and Tested ExamplesTutorial

How to Get a Claude API Key in 2026: Official Setup, Alternatives, and Tested Examples

"Learn how to get a Claude API key in 2026 from Anthropic or through Crazyrouter. Includes official setup steps, tested API examples, common problems, and a direct-vs-gateway comparison."

Mar 15
Gemini CLI Complete Guide 2026: Repo Automation, CI Agents, and Multi-Model RoutingTutorial

Gemini CLI Complete Guide 2026: Repo Automation, CI Agents, and Multi-Model Routing

If you searched for **gemini cli complete guide**, you probably do not need another shallow feature list. You need to know what Gemini CLI is, how it compares with alternatives, how to use it in a dev...

May 26
Groq API Complete Guide: The Fastest AI Inference Platform in 2026Tutorial

Groq API Complete Guide: The Fastest AI Inference Platform in 2026

"Complete guide to Groq API - the fastest AI inference platform. Learn about LPU technology, supported models, pricing, and how to integrate Groq's speed into your apps."

Feb 27