Gate.AI Quick Start: Access the API with Python, Node.js, and curl
Gate.AI provides an OpenAI-compatible API interface. Developers can send chat completion requests via Python, Node.js, curl, and other compatible AI development tools. If you’ve already used an OpenAI-style SDK or REST requests, connecting to the Gate.AI API usually just requires swapping your API key and Base URL. You don’t need to change the request structure. This quick start guide includes a required configuration step, one connection-path selection, and three mutually exclusive implementations in Python, Node.js, and curl. Advanced topics such as streaming architecture, account permissions, production monitoring, and billing controls are out of scope for this guide.
Prerequisites
- A Gate.AI API Key.
- Python, Node.js, or curl installed (depending on the integration method you choose).
What you’ll be able to do after completing this guide
After completing this Gate.AI API quick start guide, you’ll be able to successfully send chat completion requests to Gate.AI using your chosen Python, Node.js, or curl method.
You don’t need to complete examples in all three languages. Just choose the path that matches your application environment. The examples use Gate.AI’s OpenAI-compatible Base URL and chat completion format, based on the product version as of June 2026. For product background, visit Gate.AI product page.
Step 1: Set up common Gate.AI API configuration
This step prepares the common API configuration parameters for all integration paths.
Action:
Before choosing an implementation path, use the following Gate.AI API configuration parameters.
| Configuration item | Value |
|---|---|
| API Key | YOUR_GATEAI_API_KEY |
| Base URL | xx/openai/v1 |
| Chat completions endpoint | xx/openai/v1/chat/completions |
| Python example model value | auto |
| Node.js example model value | auto |
| curl example model value | deepseek/deepseek-v3.2 |
The API key is used for request authentication. The Base URL routes calls from OpenAI-compatible SDKs to Gate.AI. For the curl path, you must use the Endpoint directly.
Step 2: Choose an API integration path
This step ensures the Python, Node.js, and curl examples aren’t mistaken as all required to run.
Action:
Pick one path from the table below.
| Integration path | Suitable scenarios | Required environment | Next step |
|---|---|---|---|
| Python | Your app, scripts, or backend uses Python | Python and OpenAI Python SDK | Step 3A |
| Node.js | Your app or service uses JavaScript or Node.js | Node.js and OpenAI Node.js SDK | Step 3B |
| curl | You need to test directly in the terminal or debug REST requests | curl | Step 3C |
Completing just one path is enough to verify your Gate.AI API integration. Only run multiple paths if you need to test Gate.AI across multiple development environments.
Step 3A: Send a Python chat completion request
This path uses the OpenAI Python SDK and specifies the Gate.AI Base URL.
Action:
Use this path only if your environment is Python.
from openai import OpenAIclient = OpenAI(api_key="YOUR_GATEAI_API_KEY",base_url="https://api.gate.ai/openai/v1",)completion = client.chat.completions.create(model="auto",messages=[{"role": "system", "content": "system prompt"},{"role": "user", "content": "how are you?"}],)print(completion.choices[0].message.content)
You’ll see the assistant’s reply in your terminal, for example:
Hello! Nice to meet you. How can I help you?
This path keeps the OpenAI Python SDK request structure. You only replace the API key and Base URL with Gate.AI.
Step 3B: Send a Node.js chat completion request
This path uses the OpenAI Node.js SDK and specifies the Gate.AI Base URL.
Action:
Use this path only if your environment is Node.js.
const OpenAI = require("openai")const client = new OpenAI({apiKey: "YOUR_GATEAI_API_KEY",baseURL: "https://api.gate.ai/openai/v1",})async function main() {const completion = await client.chat.completions.create({model: "auto",messages: [{"role": "system", "content": "system prompt"},{"role": "user", "content": "how are you?"}],})console.log(completion.choices[0].message.content)}main()
You’ll see the assistant’s reply in the console. If your script prints nothing when it runs, print the full completion object to confirm that the choices[0].message.content field exists.
Step 3C: Send a curl chat completion request
This path doesn’t require an SDK. You call the Gate.AI chat completions endpoint directly.
Action:
Use this path only when you want to send a REST request directly from the terminal.
curl --location --request POST 'https://api.gate.ai/openai/v1/chat/completions' \--header 'Authorization: Bearer YOUR_GATEAI_API_KEY' \--header 'Content-Type: application/json' \--data-raw '{"model": "deepseek/deepseek-v3.2","stream": false,"messages": [{"role": "user","content": "how are you"}]}'
You’ll receive a JSON response that includes the choices array. The assistant’s reply is in choices[0].message.content.
Example: Successful Gate.AI API response
A successful Gate.AI chat completion response follows the OpenAI-compatible structure.
{"id": "243c850e-214c-431e-977f-ebaf4aa95f56","choices": [{"index": 0,"message": {"role": "assistant","content": "Hello! Nice to meet you. How can I help you?"},"finish_reason": "stop"}],"created": 1773408946,"model": "deepseek.v3-v1:0","object": "chat.completion","usage": {"prompt_tokens": 5,"completion_tokens": 15,"total_tokens": 20}}
| Response field | What to check |
|---|---|
| choices[0].message.content | The generated assistant reply content |
| finish_reason | Whether the model stopped normally |
| model | The model actually used for the request |
| usage.prompt_tokens | Number of tokens consumed by the input messages |
| usage.completion_tokens | Number of tokens consumed by the assistant reply |
| usage.total_tokens | Total number of tokens consumed by the request and reply |
For quick testing, the most critical field is choices[0].message.content. The usage object helps confirm that Gate.AI processed the prompt and generated the reply as expected.
Common reasons for failed Gate.AI API requests and troubleshooting
- Symptom: The request returns an authentication error.
- Cause: API key missing, expired, incorrect format, or not copied correctly from Gate.AI.
- Fix: Replace
YOUR_GATEAI_API_KEYwith a valid Gate.AI API key. For curl, keep the header formatAuthorization: Bearer YOUR_GATEAI_API_KEY.
- Symptom: The SDK request is sent to the wrong service.
- Cause: The OpenAI SDK is still using the default Base URL.
- Fix: In Python, set
base_url. In Node.js, setbaseURLtohttps://api.gate.ai/openai/v1, then send the request again.
- Symptom: The response doesn’t use the expected model.
- Cause: You used
auto, or Gate.AI mapped it to a different model ID during automatic model selection.
- Cause: You used
- Symptom: The script runs but prints nothing.
- Cause: The code doesn’t read
completion.choices[0].message.content, or the request failed before printing.
- Cause: The code doesn’t read
Next steps: configurable or integrable items
After completing any Gate.AI quick start API path, you can integrate the same Gate.AI Base URL into your application backend, developer tools, internal automation, or testing workflows.
Recommended follow-up topics:
- Learn how Gate.AI fits into your AI development workflow: see Gate.AI product overview.
- Read Gate.AI API documentation for supported API behaviors, model details, and implementation references.
FAQs
Do I need to run Python, Node.js, and curl at the same time?
No. Choose one integration path based on your development environment. Python, Node.js, and curl are just different ways to send Gate.AI chat completion requests.
Why does Python use base_url, while Node.js uses baseURL?
The Python SDK uses snake_case naming, while the Node.js SDK uses camelCase naming. Both point to the same Gate.AI Base URL.
Can I use model="auto" for every request?
You can use auto when you want Gate.AI to automatically select a model and your configuration supports it. If you want to specify a model, refer to the Gate.AI documentation for the model ID you want to use.
Where is the assistant reply in the JSON output?
The assistant reply is in choices[0].message.content. Token usage is shown separately in the usage object.