Create an AI API¶
What happens
An API creator exposes an AI service, such as OpenAI, Azure OpenAI or Mistral, through APIM. They pick an LLM provider, which an admin has registered with its API definition and models. APIM creates a normal API (AM_API plus resources) and links it to the provider through AM_API_AI_CONFIGURATION. Subscription tiers can then limit tokens, not just requests.
Who: Admin (registers providers), API creator (Publisher) · Tables written: AM_LLM_PROVIDER + AM_LLM_PROVIDER_MODEL (at startup or by an admin), AM_API, AM_API_LC_EVENT, AM_API_URL_MAPPING, AM_API_AI_CONFIGURATION, AM_API_PRIMARY_EP_MAPPING, GOV_*, REG_* · Tables read: AM_POLICY_SUBSCRIPTION
How the tables connect¶
An AI API is a normal API with one extra link to the provider it fronts.
erDiagram
AM_LLM_PROVIDER ||--o{ AM_LLM_PROVIDER_MODEL : "offers"
AM_LLM_PROVIDER ||--o{ AM_API_AI_CONFIGURATION : "used by"
AM_API ||--o{ AM_API_AI_CONFIGURATION : "configured by"
AM_API ||--o{ AM_API_PRIMARY_EP_MAPPING : "primary endpoint"
- There's one AI configuration row per API per revision, so revisions snapshot the provider choice too.
The flow at a glance¶
sequenceDiagram
actor Admin
actor Creator as API creator
participant Pub as Publisher / Admin Portal
participant DB as APIM DB
Admin->>Pub: Register provider (built-ins are seeded at startup)
Pub->>DB: insert AM_LLM_PROVIDER + AM_LLM_PROVIDER_MODEL
Creator->>Pub: Create AI API from OpenAI
Pub->>DB: insert AM_API (API_SUBTYPE = AIAPI) + URL mappings
Pub->>DB: insert AM_API_AI_CONFIGURATION
Pub->>DB: insert AM_API_PRIMARY_EP_MAPPING
- After this, the API is revisioned, deployed, published and subscribed to exactly like any other API (flows 4–10).
Step by step¶
-
Provider registration (admin, or built in).
AM_LLM_PROVIDERholdsUUID,NAME,API_VERSIONandORGANIZATION.BUILT_IN_SUPPORTis true for providers that ship with APIM.CONFIGURATIONSholds how to read token counts, the model name and so on from responses.API_DEFINITIONholds the provider's OpenAPI.(NAME, API_VERSION, ORGANIZATION)is unique.
UUID NAME API_VERSION BUILT_IN_SUPPORT ORGANIZATION 4d78…OpenAI 2.0.0 true carbon.super -
Models.
AM_LLM_PROVIDER_MODELlists the models the provider offers, withMODEL_NAME,MODEL_FAMILY_NAMEandLLM_PROVIDER_UUID(a real FK).MODEL_ID MODEL_NAME MODEL_FAMILY_NAME LLM_PROVIDER_UUID 18 gpt-4o OpenAI 4d78…19 gpt-4o-mini OpenAI 4d78…20 o3-mini OpenAI 4d78… -
The API itself. An
AM_APIrow is created withAPI_TYPE = 'HTTP'andAPI_SUBTYPE = 'AIAPI', which is what marks it as an AI API. Its resources, e.g.POST /chat/completions, are stored inAM_API_URL_MAPPINGlike any other API's.API_ID API_UUID API_NAME CONTEXT API_TYPE API_SUBTYPE STATUS 4 e6c6…ChatAPI /chat/1.0.0 HTTP AIAPI CREATED -
The link.
AM_API_AI_CONFIGURATIONholdsAI_CONFIGURATION_UUID,API_UUID(FK),API_REVISION_UUIDandLLM_PROVIDER_UUID(FK). For the working copyAPI_REVISION_UUIDisNULL. When a revision is created, a copy with the revision's UUID is expected, though revisions of the AI API weren't tested.AI_CONFIGURATION_UUID API_UUID API_REVISION_UUID LLM_PROVIDER_UUID 796b…e6c6…(null) 4d78…(OpenAI 2.0.0) -
Endpoints and secrets.
AM_API_PRIMARY_EP_MAPPINGrecords which endpoint is primary:(API_UUID, ENDPOINT_UUID = 'default_production_endpoint', REVISION_UUID = 'Current API'). The default endpoint defined at creation time stayed in the registry artifact; noAM_API_ENDPOINTSrow was written. Extra named endpoints, used for model routing and failover, go intoAM_API_ENDPOINTSwith their URL and API key in theENDPOINT_CONFIGblob. Per-environment keys can go intoAM_API_ENVIRONMENT_KEYS. -
Token-based limits. A subscription tier can cap AI usage through the
AM_POLICY_SUBSCRIPTIONcolumnsTOTAL_TOKEN_COUNT,PROMPT_TOKEN_COUNTandCOMPLETION_TOKEN_COUNT, withQUOTA_TYPE = 'aiApiQuota'. The seeded tiersAIGold,AISilverandAIBronzeare of this type (e.g. AIGold: 500 requests and 50000 total tokens per minute).
What gets cleaned up¶
- The FKs from
AM_API_AI_CONFIGURATIONandAM_LLM_PROVIDER_MODELhave no ON DELETE rule. You can't delete a provider while APIs use it, or while it still has model rows. - APIM's code removes the AI configuration when the API is deleted.
Try it¶
This query lists the AI APIs, the provider behind each one, and the provider's models.
SELECT a.API_NAME, a.API_VERSION, p.NAME AS PROVIDER, p.API_VERSION AS PROVIDER_VERSION,
m.MODEL_NAME
FROM AM_API_AI_CONFIGURATION c
JOIN AM_API a ON a.API_UUID = c.API_UUID
JOIN AM_LLM_PROVIDER p ON p.UUID = c.LLM_PROVIDER_UUID
LEFT JOIN AM_LLM_PROVIDER_MODEL m ON m.LLM_PROVIDER_UUID = p.UUID
WHERE c.API_REVISION_UUID IS NULL OR c.API_REVISION_UUID = 'Current API';
Different in 3.x
AI APIs don't exist in 3.x. There are no LLM provider or AI configuration tables. The 3.x flows have no equivalent page.
Related domains: AI APIs · API definition · Throttling policies