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

// 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, and models.
  • 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 200 with status: "invalid" and the reason in lastError.
  • Agent fallback models (fallbackModels): adding a new fallback to an agent requires at least one own key that is connected (otherwise 422 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_DENIED or 403 FORBIDDEN if missing). With an API key you have full access.

States

  • status: not_connected (uses Platica's account), verifying, connected (active), invalid (failed; see lastError), 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), and no_model_access. Changes trigger the model_provider.status.updated webhook.
  • Per model (models[].status): available, unavailable (code: AUTH_INVALID, AUTH_OR_PERMISSION, MODEL_OR_DEPLOYMENT_NOT_FOUND, NO_CREDIT, QUOTA_OR_RATE_LIMIT, TIMEOUT), or unverified.

The fallback

fallback defines what your agents do if your own key fails:

  • platform (default): they answer using Platica's account (it charges AI; ownKeyOnly models do not answer).
  • none: they stop answering with that provider's models.

Endpoints

MethodEndpointWhat it does
GET/v1/ai-providersList 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}/verifyTest 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.