OpenAI-Compatible API
โ ๏ธ BETA: GMTech's API is currently in beta testing. We welcome your feedback!
GMTech provides a fully OpenAI-compatible API as a drop-in replacement for OpenAI's API, with access to 15+ AI providers.
Why GMTech?
- Single API, Multiple Providers - Access OpenAI, Anthropic, Google, Meta, and more
- No Vendor Lock-in - Switch models without changing code
- Transparent Pricing - Real-time cost tracking with no markup
- OpenAI Compatible - Use existing OpenAI SDK code unchanged
Quick Start
1. Install OpenAI SDK
pip install openai
2. Replace Base URL
from openai import OpenAI
# Instead of OpenAI...
# client = OpenAI(api_key="sk-...")
# Use GMTech
client = OpenAI(
base_url="https://app.gmtech.com/v1",
api_key="gmtech_your_api_key"
)
# Everything else works the same!
Chat Completions
Basic Chat
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is Python?"}
]
)
print(response.choices[0].message.content)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model |
string | โ | Required. GMTech model key (e.g. claude-sonnet-46) |
messages |
array | โ | Required. Includes role: system, user, and assistant |
temperature |
float | 0.7 |
Sampling temperature. Ignored for reasoning models (o1, o3, etc.) |
max_tokens |
integer | Provider default | Maximum tokens to generate. Honored by all providers |
Cost in Response
Every chat completion and image generation response includes a gmtech.cost_usd field with the exact USD amount charged for that request:
{
"id": "chatcmpl-123",
"choices": [...],
"usage": { "prompt_tokens": 120, "completion_tokens": 80, "total_tokens": 200 },
"gmtech": { "cost_usd": 0.000312 }
}
For image generation:
{
"created": 1677652288,
"data": [{ "url": "https://..." }],
"gmtech": { "cost_usd": 0.04 }
}
Use Any Model
# OpenAI
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)
# Anthropic Claude
response = client.chat.completions.create(
model="claude-sonnet-46",
messages=[{"role": "user", "content": "Hello!"}]
)
# Google Gemini
response = client.chat.completions.create(
model="google-gemini-25-pro",
messages=[{"role": "user", "content": "Hello!"}]
)
Image Generation
response = client.images.generate(
model="gpt-image-2", # DALL-E 3
prompt="A futuristic city with flying cars",
size="1024x1024"
)
print(response.data[0].url)
Sentiment Analysis
Analyze the emotional tone of any text block. Returns 10 sentiment dimensions scored 0โ100, powered by gpt-4o-mini structured outputs.
import requests, os
response = requests.post(
"https://app.gmtech.com/v1/sentiment",
headers={"Authorization": f"Bearer {os.environ['GMTECH_API_KEY']}"},
json={"text": "I'm really excited about this new product launch!"}
)
print(response.json()["sentiment"])
# {'Positive': 82, 'Negative': 5, 'Neutral': 13, 'Joyful': 74, 'Angry': 2, ...}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
text |
string | โ | The text block to analyze |
Response
Returns a sentiment object with 10 dimensions โ each an integer 0โ100:
Positive, Negative, Neutral, Joyful, Angry, Sad, Surprised, Confident, Anxious, Confused
Compare: Chat Completions
Run the same prompt against multiple LLM models in a single call. Returns one choice per model. Optionally saves the result as a shareable snapshot.
import requests, os
response = requests.post(
"https://app.gmtech.com/v1/compare/completions",
headers={"Authorization": f"Bearer {os.environ['GMTECH_API_KEY']}"},
json={
"models": ["gpt-4o", "claude-sonnet-46", "google-gemini-25-pro"],
"messages": [{"role": "user", "content": "Explain quantum entanglement in one sentence."}],
"gmtech": {"create_snapshot": True, "snapshot_public": True}
}
)
data = response.json()
for choice in data["choices"]:
print(choice["model"], "โ", choice["message"]["content"])
print(data["gmtech"]["snapshot_url"]) # shareable link
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
models | array | โ | Array of LLM model keys to compare |
messages | array | โ | OpenAI-format messages array |
temperature | number | Sampling temperature (default 0.7) | |
max_tokens | integer | Max tokens per model response | |
gmtech.create_snapshot | boolean | Save results as a compare snapshot (default false) | |
gmtech.snapshot_public | boolean | Make snapshot publicly shareable (default false) |
Response
Returns choices โ one entry per model โ plus a gmtech block if a snapshot was created:
{
"object": "chat.compare.completion",
"choices": [
{
"index": 0,
"model": "gpt-4o",
"message": {"role": "assistant", "content": "..."},
"finish_reason": "stop",
"usage": {"prompt_tokens": 20, "completion_tokens": 30, "total_tokens": 50},
"gmtech": {"cost_usd": 0.000312}
}
],
"gmtech": {
"snapshot_uuid": "abc123...",
"snapshot_url": "https://app.gmtech.com/snapshots/abc123..."
}
}
Compare: Image Generation
Run the same image prompt against multiple image models in a single call. Returns one image URL per model. Optionally saves the result as a shareable snapshot.
import requests, os
response = requests.post(
"https://app.gmtech.com/v1/compare/images",
headers={"Authorization": f"Bearer {os.environ['GMTECH_API_KEY']}"},
json={
"models": ["gpt-image-1", "google-imagegen-4"],
"prompt": "A futuristic city at sunset",
"gmtech": {"create_snapshot": True, "snapshot_public": True}
}
)
data = response.json()
for choice in data["choices"]:
print(choice["model"], "โ", choice["url"])
print(data["gmtech"]["snapshot_url"]) # shareable link
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
models | array | โ | Array of image model keys to compare |
prompt | string | โ | Image generation prompt |
size | string | Image dimensions (default 1024x1024) | |
gmtech.create_snapshot | boolean | Save results as a compare snapshot (default false) | |
gmtech.snapshot_public | boolean | Make snapshot publicly shareable (default false) |
Response
{
"object": "image.compare.completion",
"choices": [
{
"index": 0,
"model": "gpt-image-1",
"url": "https://storage.googleapis.com/.../abc123.webp",
"finish_reason": "stop",
"gmtech": {"cost_usd": 0.042}
}
],
"gmtech": {
"snapshot_uuid": "abc123...",
"snapshot_url": "https://app.gmtech.com/snapshots/abc123..."
}
}
Available Models
Use any model key from the GMTech model directory as the model parameter.
Browse all models โ | LLM model keys (API) โ | Image model keys (API) โ
JavaScript/TypeScript
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://app.gmtech.com/v1',
apiKey: process.env.GMTECH_API_KEY
});
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello!' }]
});
console.log(response.choices[0].message.content);
cURL
curl https://app.gmtech.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Api-Key gmtech_your_api_key" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Supported Features
| Feature | Status | Notes |
|---|---|---|
| Chat Completions | โ | Full support |
| Image Generation | โ | Multiple providers |
| Sentiment Analysis | โ | POST /v1/sentiment |
| Streaming | โ | Not supported โ always returns buffered response |
| Embeddings | โ | Not supported |
| Function Calling | ๐ | Planned |
| Vision | ๐ | Planned |
Error Handling
from openai import APIError, AuthenticationError, RateLimitError
try:
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)
except AuthenticationError:
print("Invalid API key")
except RateLimitError:
print("Rate limit exceeded")
except APIError as e:
print(f"API error: {e}")
Migration from OpenAI
Before (OpenAI)
from openai import OpenAI
client = OpenAI(api_key="sk-...")
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}]
)
After (GMTech)
from openai import OpenAI
client = OpenAI(
base_url="https://app.gmtech.com/v1", # Only change
api_key="gmtech_..." # Only change
)
response = client.chat.completions.create(
model="gpt-4o", # Can also use claude-sonnet-46, google-gemini-25-pro, etc.
messages=[{"role": "user", "content": "Hello"}]
)
Next Steps
- Code Examples - More examples in Python, JavaScript, cURL
- Authentication - API key management and security
- Overview - Complete API reference
Need help? Contact support or join office hours