Drop-in OpenAI replacement
The StudyAIMastery API speaks OpenAI’s wire protocol. Point your existing client at https://studyaimastery.com/api/v1 and use a StudyAIMastery API key. 11 text models, 8 image models, one bill.
Getting started
- Upgrade to Master tier ($197/mo).
- Create a key at /settings/api-keys. Plaintext is shown once — save it.
- Plug the key into any OpenAI SDK as a bearer token.
Authentication
Pass your key in the Authorization header. Keys start with sk-sam-.
Authorization: Bearer sk-sam-xxxxxxxxxxxxxxxxxxxxxxxx
Chat completions — curl
curl https://studyaimastery.com/api/v1/chat/completions \
-H "Authorization: Bearer $STUDYAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.4-mini",
"messages": [
{"role": "user", "content": "Say hi in one sentence."}
]
}'Chat completions — OpenAI Python SDK
from openai import OpenAI
client = OpenAI(
base_url="https://studyaimastery.com/api/v1",
api_key="sk-sam-...",
)
resp = client.chat.completions.create(
model="anthropic/claude-opus-4.7",
messages=[{"role": "user", "content": "Two sentences on Goedel."}],
)
print(resp.choices[0].message.content)Tools / function calling
Pass tools and tool_choice exactly as you would to OpenAI. Assistant responses carry tool_calls with arguments as a JSON string; send back a {"role":"tool","tool_call_id":"..."} message with the function result to continue.
resp = client.chat.completions.create(
model="openai/gpt-5.4",
messages=[{"role": "user", "content": "What's the weather in NYC?"}],
tools=[{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}],
)
tool_call = resp.choices[0].message.tool_calls[0]
# tool_call.function.name -> "get_weather"
# tool_call.function.arguments -> '{"city": "NYC"}'Streaming
Set stream=true for Server-Sent Events in OpenAI’s format. Every SDK that supports streaming against api.openai.com works out of the box.
stream = client.chat.completions.create(
model="openai/gpt-5.4",
messages=[{"role": "user", "content": "Explain entropy."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content or ""
print(delta, end="", flush=True)Embeddings
POST /api/v1/embeddings with model + input. Routes through OpenAI for text-embedding-3-small, text-embedding-3-large, and text-embedding-ada-002.
resp = client.embeddings.create(
model="text-embedding-3-small",
input=["hello world", "another doc"],
)
print(len(resp.data[0].embedding)) # 1536Max 100 inputs per request. Each input capped at 100k chars. Returns OpenAI’s response shape with our usage.cost_usd overlaid.
Image generation
curl https://studyaimastery.com/api/v1/images/generations \
-H "Authorization: Bearer $STUDYAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "fal-ai/flux-pro/v1.1-ultra",
"prompt": "A retrofuturist library, warm sunlight, cinematic"
}'Response has an OpenAI-compatible data[0].url. Some providers (notably Gemini) return a data: URI; in that case we also populate b64_json.
Models
Text
- openai/gpt-5.4-mini— ChatGPT · GPT-5.4 mini (fast & cheap)
- openai/gpt-5.4— ChatGPT · GPT-5.4 (flagship)
- openai/gpt-4o-mini— ChatGPT · GPT-4o mini (budget)
- openai/gpt-4o— ChatGPT · GPT-4o
- anthropic/claude-opus-4.7— Claude Opus 4.7 (flagship)
- anthropic/claude-sonnet-4.6— Claude Sonnet 4.6
- anthropic/claude-sonnet-4.5— Claude Sonnet 4.5
- anthropic/claude-haiku-4.5— Claude Haiku 4.5 (fast)
- google/gemini-3-flash-preview— Gemini 3 Flash
- google/gemini-2.0-flash-001— Gemini 2.0 Flash
- meta-llama/llama-3.3-70b-instruct— Llama 3.3 70B
Image
- google/gemini-2.5-flash-image— Gemini 2.5 Flash Image — fast, reliable
- google/gemini-3-pro-image-preview— Gemini 3 Pro Image
- google/gemini-3.1-flash-image-preview— Gemini 3.1 Flash Image
- fal-ai/flux-pro/v1.1-ultra— FLUX 1.1 Pro Ultra — artistic
- black-forest-labs/flux-1.1-pro— FLUX 1.1 Pro — artistic
- openai/gpt-image-1— GPT Image 1 (OpenAI flagship)
- openai/dall-e-3— DALL-E 3
Or discover programmatically: GET /api/v1/models
Limits
- 1,000 chat completions / day per user, reset at 00:00 UTC.
- 200 image generations / day.
- 10 active API keys per user (create/revoke from settings).
- 40,000-char message cap per message in a chat completion request.
Errors
Error shape matches OpenAI — {"error": {"message": "...", "type": "..."}}.
- 401 invalid_api_key
- 403 insufficient_tier
- 400 invalid_request_error
- 429 rate_limit_exceeded
- 502 upstream_error