API connection guide

Connect your app to e-Gate AI Gateway in minutes — just swap the base URL and API key.

1. Overview & Base URL

e-Gate AI Gateway is an OpenAI-compatible API. Call every model through a single base URL. API keys embed the serving server (machineId) — the gateway routes requests to the right server automatically:

  • sk-61d35a1d80f1d3dd-... Server 1
  • sk-9357e1fe59b66398-... Server 2

Create a key in the dashboard and the gateway handles the rest — no extra configuration needed.

2. Create an API key

Sign in to the dashboard → API Keys → pick a server, name the key, set a budget → Create. The full key (sk-<machineId>-...) is shown only once — copy and store it immediately.

3. Authentication

Every request must include an Authorization header with a Bearer token using your key:

Authorization: Bearer sk-61d35a1d80f1d3dd-YOUR-KEY

Base URL

All requests go to a single endpoint. Drop the per-provider base URLs you used before.

https://agent.e-gate.vn/v1

4. First model call (curl)

Replace YOUR-KEY with your key. Valid models include: gpt-4o, claude-3-5-sonnet, gemini-2.0-flash, deepseek-chat — see the full list on the Prices page.

curl https://agent.e-gate.vn/v1/chat/completions \
  -H "Authorization: Bearer sk-61d35a1d80f1d3dd-YOUR-KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{ "role": "user", "content": "Hello!" }]
  }'

5. SDKs (Python / Node.js)

e-Gate is fully compatible with the official OpenAI SDKs — just point base_url to e-Gate and swap the api_key:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.deepseek.com" # ← use https://agent.e-gate.vn/v1,
    api_key="sk-61d35a1d80f1d3dd-YOUR-KEY",
)

resp = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)

Streaming (SSE):

stream = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}],
    stream=True,
)

for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://agent.e-gate.vn/v1',
  apiKey: 'sk-61d35a1d80f1d3dd-YOUR-KEY',
});

const resp = await client.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(resp.choices[0].message.content);

IDE & client setup

Configure popular tools with your base URL and API key.

Cursor
# Cursor → Settings → Models → Add custom model
Name:        gateway
Base URL:    https://agent.e-gate.vn/v1
API Key:     sk-61d35a1d80f1d3dd-YOUR-KEY
Model ID:    gpt-4o   (or any model from /v1/models)

Image & Video Generation

When the server has media providers configured, call these OpenAI-compatible endpoints:

# Image generation
curl https://agent.e-gate.vn/v1/images/generations \
  -H "Authorization: Bearer sk-61d35a1d80f1d3dd-YOUR-KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"dall-e-3","prompt":"a cat","n":1,"size":"1024x1024"}'

# Video generation (when provider available, e.g. veo/kling/seedance)
curl https://agent.e-gate.vn/v1/videos/generations \
  -H "Authorization: Bearer sk-61d35a1d80f1d3dd-YOUR-KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"veo-3","prompt":"a running dog"}'

8. Common errors & support

Error codes you may encounter:

  • 401Missing or invalid Authorization — check your key is active and matches the server.
  • 402Key budget exhausted — top it up in the dashboard.
  • 404Wrong path or unknown model — verify /v1/chat/completions and the model name.
  • 429Too many requests or overall credit exhausted — slow down or top up.

Need help? Contact the e-Gate Center fanpage or email [email protected].

e-Gate AI Gateway logoAI Gateway
© 2026 e-Gate AI Gateway. All rights reserved.