Futures
Access hundreds of perpetual contracts
CFD
Gold
One platform for global traditional assets
Options
Hot
Trade European-style vanilla options
Unified Account
Maximize your capital efficiency
Demo Trading
Introduction to Futures Trading
Learn the basics of futures trading
Futures Events
Join events to earn rewards
Demo Trading
Use virtual funds to practice risk-free trading
CFD
U.S. stock CFD derivatives
US Stocks
Access real US stocks and ETFs
HK Stocks
Trade quality Hong Kong-listed stocks
Stock Futures
High leverage, 24/7 trading
Tokenized Stocks
Backed by real stock assets
IPO Access
Unlock full access to global stock IPOs
GUSD
Mint GUSD for Treasury RWA yields
Stocks Activities
Trade Popular Stocks and Unlock Generous Airdrops
Launch
CandyDrop
Collect candies to earn airdrops
Launchpool
Quick staking, earn potential new tokens
HODLer Airdrop
Hold GT and get massive airdrops for free
IPO Access
Unlock full access to global stock IPOs
Alpha Points
Trade on-chain assets and earn airdrops
Futures Points
Earn futures points and claim airdrop rewards
Promotions
AI
Gate AI
Your all-in-one conversational AI partner
Gate AI Bot
Use Gate AI directly in your social App
GateClaw
Gate Blue Lobster, ready to go
Gate for AI Agent
AI infrastructure, Gate MCP, Skills, and CLI
Gate Skills Hub
10K+ Skills
From office tasks to trading, the all-in-one skill hub makes AI even more useful.
How to Integrate Gate.AI: A Quick Start for Developers
Gate.AI API integration allows developers to access multiple AI models via a compatible OpenAI API, enabling unified model access, routing, and testing without maintaining SDK configurations for each service provider. Whether building chatbots, internal tools, intelligent agents, automation workflows, or model evaluation scripts, it greatly simplifies the integration process. This guide covers creating API keys, automatic routing, manual model selection, OpenAI-compatible base URLs, initial request testing, and troubleshooting common configuration errors, but does not include advanced topics like enterprise governance, billing strategies, or custom security architectures.
Prerequisites:
What capabilities will you gain after completing this guide?
After completing this guide, you will be able to create a Gate.AI API key, configure an OpenAI-compatible base URL, send your first API request with model: "auto", and test with a specific model ID.
What applications can developers build using Gate.AI API integration?
Developers can leverage the Gate.AI API to access multiple models through a unified OpenAI-compatible request format. Typical use cases include:
| Build Type | Role of Gate.AI | Example Output | | ------------------ | ------------------------------------- | ---------------------------------- | | Chat applications | Route user messages to supported chat models | Customer support assistant | | Internal tools | Unified API configuration across teams | AI writing/research assistant | | Intelligent agents and workflows | Connect model calls and automate tasks | Tool invocation assistant | | Model testing | Compare auto routing with fixed model ID | Evaluation scripts | | Migration projects | Replace existing OpenAI-compatible base URL | Multi-model prototypes |
When you want Gate.AI to automatically select a model, use model: "auto"; if you need reproducible behavior for a specific model, specify the exact model ID.
What should you prepare before starting?
Before starting, only two key conditions need to be met:
| Necessary Condition | Important Reason | | --------------------- | -------------------------------------------------------------- | | Gate.AI account access | To create API keys in Console and check routing settings | | Local request method | To send test requests via Python, Node.js, or curl |
You do not need to select all models upfront. Confirm API key and base URL are available, then test manual model selection.
Step 1: Create a Gate.AI API key
This step creates credentials for your application to authenticate API requests.
Procedure:
You will see the new key in the API key area. If only shown once, be sure to copy it before closing the creation window.
Step 2: Choose automatic routing or manual model selection
This step determines whether Gate.AI automatically assigns a model or you specify one in the request.
Procedure:
| Mode Selection | Request Parameter Value | Use Case | | ------------------ | ------------------------------------------- | ------------------------------------------- | | Automatic routing | "model": "auto" | When Gate.AI should auto-route requests | | Manual model selection | "model": "anthropic/claude-sonnet-4.6" | For testing or using a specific model ID |
Auto-routing is suitable for quick access and general routing tests; manual selection is for reproducible evaluation of a single model.
Step 3: Configure OpenAI-compatible base URL
This step redirects existing OpenAI-style clients to Gate.AI instead of the default OpenAI endpoint.
Use the following base URL:
text
Authentication format:
text Authorization: Bearer YOUR_API_KEY
Gate.AI documentation specifies that the API path should be /openai/v1, not just /v1 (as of June 2026). Be sure to fill in the complete base URL exactly as shown.
| Configuration Item | Value | | ------------------ | ---------------------------------------------- | | Base URL | [your base URL here] | | Authentication | Authorization: Bearer YOUR_API_KEY | | Format | Compatible with OpenAI | | Chat endpoint | POST /chat/completions | | Model list endpoint | GET /models |
Most integration errors stem from incorrect base URL abbreviations or copying the API key incorrectly. Confirm these two are correct before adjusting model configurations.
Step 4: Send your first API request
This step tests whether the API key, base URL, and OpenAI-compatible chat format work together.
Python example:
python from openai import OpenAI
client = OpenAI( api_key="YOUR_API_KEY", base_url="", )
completion = client.chat.completions.create( model="auto", messages=[ {"role": "system", "content": "You are a concise assistant."}, {"role": "user", "content": "Say hello from Gate.AI."} ], )
print(completion.choices[0].message.content)
Node.js example:
javascript import OpenAI from "openai";
const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "", });
const completion = await client.chat.completions.create({ model: "auto", messages: [ { role: "system", content: "You are a concise assistant." }, { role: "user", content: "Say hello from Gate.AI." } ], });
console.log(completion.choices[0].message.content);
curl example:
bash curl /chat/completions
-H "Authorization: Bearer YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{ "model": "auto", "messages": [ {"role": "system", "content": "You are a concise assistant."}, {"role": "user", "content": "Say hello from Gate.AI."} ] }'
You should receive a normal assistant reply. If authentication errors occur, check the API key first; no need to modify code immediately.
Step 5: Test with a specific model ID
This step verifies that manual model selection works when needed.
Change the model parameter from auto to a specific supported model ID:
python from openai import OpenAI
client = OpenAI( api_key="YOUR_API_KEY", base_url="", )
completion = client.chat.completions.create( model="anthropic/claude-sonnet-4.6", messages=[ {"role": "user", "content": "Explain model routing in one paragraph."} ], )
print(completion.choices[0].message.content)
Be sure to enter the model ID exactly as specified in Gate.AI’s model documentation or list. Typos will cause requests to fail even if the API key and base URL are correct.
How does Gate.AI’s automatic routing mechanism work in API requests?
Gate.AI’s auto-routing uses "model": "auto" in the request body, combined with routing settings in the Console, to automatically select a model for the request. As of June 2026, routing controls are managed via Console → Settings → Routing.
| Routing Method | Configuration Location | API Request Parameter | | ------------------ | ------------------------------------------ | --------------------------------- | | Automatic routing | Console → Settings → Routing | "model": "auto" | | Manual model choice | In the request body | Specify model ID | | Routing policy control | Console routing settings | Custom behavior organization |
Auto-routing does not mean omitting the model field. You must explicitly include the model field with value "auto" for Gate.AI to auto-route.
Which integration method should you choose?
Select based on your application environment:
| Method | Use Case | Main Changes | | ---------------------------- | ------------------------------------------- | ---------------------------------- | | Python SDK | Existing Python backend scripts or services | Set base_url and api_key | | Node.js SDK | Using JavaScript or TypeScript services | Set baseURL and apiKey | | curl | Quick manual validation | Send request headers and JSON payload | | Existing OpenAI-compatible app | Support for custom base URL | Replace base URL and API key |
Most developers recommend quick validation with curl first, then integrating with Python or Node.js into actual applications.
Common reasons for Gate.AI API request failures
When facing issues, troubleshoot step-by-step:
| Symptom | Cause Explanation | Solution | | ------------------------------------- | -----------------------------------------------------| ----------------------------------------------------- | | 401 or invalid API key | Missing, expired, or incorrectly copied API key, or missing Bearer token | Recreate/copy key, use Authorization: Bearer YOUR_API_KEY | | Model not found | Wrong or unavailable model ID in request | Check Gate.AI model documentation or test with model: "auto" | | OpenAI-compatible code errors immediately | Incomplete base URL or only /v1 filled in | Use full URL as shown in examples | | Auto-routing not working as expected | Auto-routing disabled or routing settings misconfigured | Enable Console → Settings → Routing, check auto-routing toggle | | Empty or error response | Request format error or unsupported model for current request | Test minimal chat request first, then add parameters gradually |
Start troubleshooting from authentication, base URL, and model ID. Most quick access issues are resolved through these three steps.
What additional configurations are available after initial success?
Once your first request succeeds, you can expand integration by:
FAQs
Why is it recommended to prioritize model: "auto"?
Using model: "auto" first verifies API key, base URL, request format, and routing configuration in one go. After confirming correctness, test with specific model IDs.
Can I use existing OpenAI SDKs to call Gate.AI?
Yes. Gate.AI supports OpenAI-compatible API formats. Just set your Gate.AI API key and replace the base URL with your Gate.AI URL.
Why do requests fail after switching to a specific model?
The model ID may not exist, be misspelled, or your account may not support it. Confirm the model ID in Gate.AI’s documentation before retrying.
When using a specific model, should I disable auto-routing?
Not necessarily. When manually selecting a model, you can pass the model ID directly in the request. If behavior is unexpected, check routing settings in the console.