AI providers
Agents use Platica's AI account by default. Connect your own OpenAI, Google, Anthropic, or xAI key to bill that provider's models to your account. This also enables models that require your own key.
Quick example
curl -X PUT https://api.platic.ai/v1/ai-providers/openai \
-H "Authorization: Bearer $PLATIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{"value": "sk-...", "fallback": "platform"}' // Connecting also tests the key against the provider's models (up to 200 s)
const openai = await platic.aiProviders.connect('openai', {
value: process.env.OPENAI_API_KEY!,
fallback: 'platform'
});
if (openai.status !== 'connected') {
console.log(openai.health, openai.lastError);
} What you need to know
- Protected key: it is stored encrypted as a secret. Responses include only
status,health,fallback,secretName, andmodels. - Key test: connecting or verifying generates a short response per model. It uses a few tokens and may take up to 200 s. Each provider allows 10 tests/hour. A failed test returns
200withstatus: "invalid"and the reason inlastError. - Agent fallback models (
fallbackModels): adding a new fallback to an agent requires at least one own key that isconnected(otherwise422 MODEL_FALLBACKS_REQUIRE_OWN_KEY). With Platica's account it is not needed. - Permissions: with OAuth it requires Integrations, Settings -> Models (BYOK), and secrets permissions (
403 MODELS_ACCESS_DENIEDor403 FORBIDDENif missing). With an API key you have full access.
States
status:not_connected(uses Platica's account),verifying,connected(active),invalid(failed; seelastError),disabled.health:ok,key_rejected,no_credit(if it ran out of balance while in use, it retries every 10 min and recovers on its own when you top up), andno_model_access. Changes trigger themodel_provider.status.updatedwebhook.- Per model (
models[].status):available,unavailable(code:AUTH_INVALID,AUTH_OR_PERMISSION,MODEL_OR_DEPLOYMENT_NOT_FOUND,NO_CREDIT,QUOTA_OR_RATE_LIMIT,TIMEOUT), orunverified.
The fallback
fallback defines what your agents do if your own key fails:
platform(default): they answer using Platica's account (it charges AI;ownKeyOnlymodels do not answer).none: they stop answering with that provider's models.
Endpoints
| Method | Endpoint | What it does |
|---|---|---|
GET | /v1/ai-providers | List the 4 providers, their state and models |
PUT | /v1/ai-providers/{provider} | Connect or replace the key and test it |
POST | /v1/ai-providers/{provider}/verify | Test the stored key again |
PATCH | /v1/ai-providers/{provider} | Change fallback (platform or none) |
DELETE | /v1/ai-providers/{provider} | Disconnect the key |
Errors (INVALID_PROVIDER, VERIFICATION_RATE_LIMITED, VERIFICATION_FAILED, MODELS_ACCESS_DENIED) are in Errors and AI tools in AI providers MCP.