AI Gateway Reference

VerifiedSafe

Reference for the studio/ai-gateway service — the single shared entry point every other service uses to reach Claude, Gemini, and MiniMax.

Sby Skills Guide Bot
DevelopmentIntermediate
7/22/2026
Claude CodeCursorWindsurfCopilotCodex
#ai-gateway#llm-routing#system-prompts#cost-tracking#microservices

Recommended for

Automated summary

Reference documentation for the internal ai-gateway service, the single shared entry point every other service uses to reach Claude, Gemini and MiniMax.

Strengths

  • Precisely documents the four endpoints (/ai/chat, /ai/translate, /ai/transcribe, /ai/tts) with payloads and the provider each routes to
  • Enforces a system-prompt registry kept in separate files so prompts can be edited outside application code
  • Makes cost logging mandatory and positions it as the first debugging step for AI issues
  • Gives a clear five-step checklist for adding a new AI capability

Limitations

  • Tightly coupled to this studio's internals (studio/ai-gateway, Supabase, store/bots/dubbing services)
  • Does not embed the detailed prompt specs, which live in other skills
  • Says nothing about authentication, error handling, or rate limits on the endpoints
When to use it

Use it when a service needs a new AI capability, when editing system prompts or tool definitions, or when changing which provider handles a given task.

When not to use it

Not useful outside this monorepo, or for learning the full content of a specific prompt or dubbing pipeline.

Security analysis

Safe
Quality score92/100

This is a reference document describing an internal AI gateway service, its endpoints, prompt registry, cost logging, and process for adding capabilities. It contains no executable commands, no destructive actions, no data exfiltration, and no instructions to bypass safety. The only network references are descriptive API endpoint examples, not instructions to execute them.

No concerns found

How this analysis is made

Examples

Ajouter un contexte de chat
The support widget needs an AI reply for order tracking. Should I add a new endpoint in studio/ai-gateway or just a new context value on /ai/chat? Walk me through the steps and the prompt file I need to create.
Modifier un prompt système
Update the system prompt used by the fb-ig-comment bot so replies are shorter and match our public brand voice, and tell me which file under studio/ai-gateway/prompts/ to edit.
Déboguer un appel IA
Our Telegram bot gave a strange answer yesterday. Show me where to look in the ai_requests table in Supabase to see what was sent to Claude, what came back, and what it cost.

name: ai-gateway description: "Reference for the studio/ai-gateway service — the single shared entry point every other service uses to reach Claude, Gemini, and MiniMax. Use this when any service needs a new AI capability, when adding/editing system prompts or tool definitions, or when changing which provider handles which task."

AI Gateway — Reference

Purpose

One internal service that all other services call for any AI capability. No service (store, bots, dubbing) holds an AI provider API key or calls Claude/Gemini/MiniMax directly. This is what makes "swap providers" or "add logging" a one-place change instead of a three-place change.

Endpoints

POST /ai/chat

{
  "context": "store-chat | store-admin | telegram-fb-ig-dm | fb-ig-comment",
  "message": "user's message",
  "history": [ /* prior turns, optional */ ]
}
  • context selects the system prompt AND, for store-admin, the available tools (see medusa-store skill for the tool list)
  • Routes to Claude (this is the default chat/agent provider)
  • Returns { reply, tool_calls?: [...] }

POST /ai/translate

{
  "context": "dubbing-sorani-to-iraqi",
  "text": "chunk text",
  "duration_seconds": 3.2
}
  • Routes to MiniMax (see video-dubbing skill for the prompt spec)

POST /ai/transcribe

{ "audio_url": "...", "language_hint": "ku" }
  • Routes to Gemini for Sorani ASR
  • Returns { chunks: [{ text, start_time, end_time }] }

POST /ai/tts

{ "text": "...", "voice": "iraqi-arabic-default", "provider": "minimax | chatterbox" }
  • provider defaults to minimax; switch to chatterbox once self-hosted (see video-dubbing skill)

System Prompt Registry

Each context value maps to one system prompt, stored as a separate file under studio/ai-gateway/prompts/<context>.md — never inline in code, so non-developers (and other agents) can review/edit prompts without touching application code.

| Context | Used by | Contains | |---|---|---| | store-chat | Store widget | Product catalog, FAQ, store policies (Arabic) | | store-admin | Store admin agent | Tool definitions + Arabic admin persona | | telegram-fb-ig-dm | Bot Bridge | Store knowledge + conversational DM persona | | fb-ig-comment | Comment Bot | Shorter, public brand-voice persona | | dubbing-sorani-to-iraqi | Dubbing, step 2 | Dialect/register translation spec |

Cost Logging (mandatory)

Every request to this service writes one row to the ai_requests or ai_usage_logs table (Supabase): { timestamp, context, provider, model, input_tokens, output_tokens, estimated_cost }. This is the FIRST place the debugger agent should look for any AI-related issue — it shows exactly what was sent/received and what it cost, across every service.

Adding a New AI Capability

  1. Does an existing endpoint cover it? (most "new AI features" are just a new context value on /ai/chat)
  2. If genuinely new, add an endpoint here — never let another service call a provider directly, even "just this once"
  3. Add the system prompt file under studio/ai-gateway/prompts/
  4. Add cost logging for the new call path
  5. Update the table above

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/ai-gateway-reference-mrwaka5r/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/ai-gateway-reference-mrwaka5r' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/ai-gateway-reference-mrwaka5r/download' --output '.skill-downloads/ai-gateway-reference-mrwaka5r/SKILL.md.part' && mv '.skill-downloads/ai-gateway-reference-mrwaka5r/SKILL.md.part' '.skill-downloads/ai-gateway-reference-mrwaka5r/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/ai-gateway-reference-mrwaka5r/SKILL.md' && test -s '.skill-downloads/ai-gateway-reference-mrwaka5r/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/ai-gateway' && cp -R '.skill-downloads/ai-gateway-reference-mrwaka5r' '.claude/skills/ai-gateway'

Cursor
test -f '.skill-downloads/ai-gateway-reference-mrwaka5r/SKILL.md' && test -s '.skill-downloads/ai-gateway-reference-mrwaka5r/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/ai-gateway' && cp -R '.skill-downloads/ai-gateway-reference-mrwaka5r' '.cursor/skills/ai-gateway'

Codex
test -f '.skill-downloads/ai-gateway-reference-mrwaka5r/SKILL.md' && test -s '.skill-downloads/ai-gateway-reference-mrwaka5r/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/ai-gateway' && cp -R '.skill-downloads/ai-gateway-reference-mrwaka5r' '.agents/skills/ai-gateway'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/ai-gateway-reference-mrwaka5r'

openskills read 'ai-gateway-reference-mrwaka5r'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/ai-gateway-reference-mrwaka5r/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills