Gate.AIBlogGate.AI Quick Start API Access with Python, Node.js, and curl

    Gate.AI Quick Start API Access with Python, Node.js, and curl

    Guides

    Gate.AI provides an OpenAI-compatible API interface that allows developers to send chat completion requests through Python, Node.js, curl, and compatible AI development tools. For developers who already use OpenAI-style SDKs or REST requests, Gate.AI API access mainly requires replacing the API key and base URL rather than changing the request structure. This quick start covers one required setup step, one access-path decision, and three mutually exclusive implementation paths for Python, Node.js, and curl; advanced topics such as streaming architecture, account permissions, production monitoring, and billing controls are outside the scope.

    Prerequisites

    • A Gate.AI API key.
    • Python, Node.js, or curl installed, depending on the access path you choose.

    What Will You Be Able to Do After This Guide?

    After completing this Gate.AI quick start API guide, you will be able to send a working chat completion request to Gate.AI using one selected access method: Python, Node.js, or curl.

    You do not need to complete all three language examples. Choose the path that matches your application environment. The examples use the Gate.AI OpenAI-compatible base URL and chat completions format as of June 2026. For product context, use the Gate.AI product page.

    Step 1: Prepare Shared Gate.AI API Values

    This step prepares the common API values required by every access path.

    Action:

    Use the following Gate.AI API configuration values before choosing your implementation path.

    Configuration item Value
    API key YOUR_GATEAI_API_KEY
    Base URL https://api.gate.ai/openai/v1
    Chat completions endpoint https://api.gate.ai/openai/v1/chat/completions
    Example Python model value auto
    Example Node.js model value auto
    Example curl model value deepseek/deepseek-v3.2

    The API key authenticates the request, while the base URL routes OpenAI-compatible SDK calls to Gate.AI. The endpoint is used directly only in the curl path.

    Step 2: Choose One API Access Path

    This step prevents the Python, Node.js, and curl examples from being treated as a required sequence.

    Action:

    Choose one path from the table below.

    Access path Use this path when Required environment Next step
    Python Your app, script, 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 want a direct terminal test or REST debugging request curl Step 3C

    Only one path is required to verify Gate.AI API access. Run multiple paths only if you want to test Gate.AI across different development environments.

    Step 3A: Send a Python Chat Completion Request

    This path uses the OpenAI Python SDK with the Gate.AI base URL.

    Action:

    Use this path only if your selected environment is Python.

    1. from openai import OpenAI
    2. client = OpenAI(
    3. api_key="YOUR_GATEAI_API_KEY",
    4. base_url="https://api.gate.ai/openai/v1",
    5. )
    6. completion = client.chat.completions.create(
    7. model="auto",
    8. messages=[
    9. {"role": "system", "content": "system prompt"},
    10. {"role": "user", "content": "how are you?"}
    11. ],
    12. )
    13. print(completion.choices[0].message.content)

    You should see an assistant response printed in the terminal, such as:

    1. Hello! Nice to meet you. How can I help you?

    This path keeps the OpenAI Python SDK request shape and changes the API key and base URL to Gate.AI.

    Step 3B: Send a Node.js Chat Completion Request

    This path uses the OpenAI Node.js SDK with the Gate.AI base URL.

    Action:

    Use this path only if your selected environment is Node.js.

    1. const OpenAI = require("openai")
    2. const client = new OpenAI({
    3. apiKey: "YOUR_GATEAI_API_KEY",
    4. baseURL: "https://api.gate.ai/openai/v1",
    5. })
    6. async function main() {
    7. const completion = await client.chat.completions.create({
    8. model: "auto",
    9. messages: [
    10. {"role": "system", "content": "system prompt"},
    11. {"role": "user", "content": "how are you?"}
    12. ],
    13. })
    14. console.log(completion.choices[0].message.content)
    15. }
    16. main()

    You should see the assistant response in the console. If the script runs without output, print the full completion object once and confirm that choices[0].message.content exists.

    Step 3C: Send a curl Chat Completion Request

    This path calls the Gate.AI chat completions endpoint directly without an SDK.

    Action:

    Use this path only if you want a direct REST request from the terminal.

    1. curl --location --request POST 'https://api.gate.ai/openai/v1/chat/completions' \
    2. --header 'Authorization: Bearer YOUR_GATEAI_API_KEY' \
    3. --header 'Content-Type: application/json' \
    4. --data-raw '{
    5. "model": "deepseek/deepseek-v3.2",
    6. "stream": false,
    7. "messages": [
    8. {
    9. "role": "user",
    10. "content": "how are you"
    11. }
    12. ]
    13. }'

    You should receive a JSON response with a choices array. The assistant reply is available at choices[0].message.content.

    What Does a Successful Gate.AI API Response Look Like?

    A successful Gate.AI chat completion response follows the OpenAI-compatible chat completion structure.

    1. {
    2. "id": "243c850e-214c-431e-977f-ebaf4aa95f56",
    3. "choices": [
    4. {
    5. "index": 0,
    6. "message": {
    7. "role": "assistant",
    8. "content": "Hello! Nice to meet you. How can I help you?"
    9. },
    10. "finish_reason": "stop"
    11. }
    12. ],
    13. "created": 1773408946,
    14. "model": "deepseek.v3-v1:0",
    15. "object": "chat.completion",
    16. "usage": {
    17. "prompt_tokens": 5,
    18. "completion_tokens": 15,
    19. "total_tokens": 20
    20. }
    21. }
    Response field What to check
    choices[0].message.content The generated assistant response
    finish_reason Whether the model stopped normally
    model The model that served the request
    usage.prompt_tokens Tokens used by the input messages
    usage.completion_tokens Tokens used by the assistant response
    usage.total_tokens Total tokens used by the request and response

    The most important field for a quick start test is choices[0].message.content. The usage object helps confirm that Gate.AI processed both the prompt and completion.

    Why Is the Gate.AI API Request Not Working? Troubleshooting Checklist

    • Symptom: The request returns an authentication error.
      • Cause: The API key is missing, expired, malformed, or not copied correctly from Gate.AI.
      • Fix: Replace YOUR_GATEAI_API_KEY with a valid Gate.AI API key. For curl, keep the Authorization: Bearer YOUR_GATEAI_API_KEY header format.
    • Symptom: The SDK request goes to the wrong service.
      • Cause: The OpenAI SDK is still using its default base URL.
      • Fix: Set Python base_url or Node.js baseURL to https://api.gate.ai/openai/v1 before sending the request.
    • Symptom: The response does not use the expected model.
      • Cause: The request uses auto, or the requested model ID is mapped differently by Gate.AI when automatic model selection is intended.
    • Symptom: The script runs but prints nothing.
      • Cause: The code may not be reading completion.choices[0].message.content, or the request failed before the print statement.

    What Can You Configure or Build Next?

    After one Gate.AI quick start API path works, connect the same Gate.AI base URL to your application backend, developer tool, internal automation, or testing workflow.

    Suggested next topics:

    FAQs

    Do I need to run Python, Node.js, and curl?

    No. Choose one access path based on your environment. Python, Node.js, and curl are alternative methods for sending a Gate.AI chat completion request.

    Why does Python use base_url while Node.js uses baseURL?

    The Python SDK uses snake_case configuration names, while the Node.js SDK uses camelCase names. Both fields point to the same Gate.AI base URL.

    Can I use model="auto" for every request?

    Use auto when automatic model selection is intended and supported by your Gate.AI setup. If your application requires a specific model, use a supported model ID from Gate.AI documentation.

    Where is the assistant response in the JSON output?

    The assistant response is in choices[0].message.content. Token usage is shown separately in the usage object.

    The content herein does not constitute any offer, solicitation, or recommendation. You should always seek independent professional advice before making any investment decisions. Please note that Gate may restrict or prohibit the use of all or a portion of the Services from Restricted Locations. For more information, please read the User Agreement

    Related Articles