Connect an AI provider key

SDK platic.aiProviders.connect()

Store and test a provider key in one call. If a key is already connected, replace it.

Example

await platic.aiProviders.connect("openai", { value: "your-openai-key" });

Path parameters

ParameterTypeDescriptionRequired
providerstringopenai, google, anthropic, or xai✓

Request body

FieldTypeDescriptionRequired
valuestringThe provider's key, up to 4,096 characters✓
fallbackstringWhat agents do while the key does not work: platform or none. Without it, the provider keeps the one it had, or platform if it is new. See the fallback—
{
  "value": "sk-proj-example",
  "fallback": "platform"
}

Response

200 OK with the provider after the test, in the shape of list AI providers. It never includes the key.

{
  "status": "success",
  "message": "Key connected and verified",
  "data": {
    "provider": "openai",
    "name": "OpenAI",
    "status": "connected",
    "health": "ok",
    "fallback": "platform",
    "lastVerifiedAt": "2026-11-13T16:20:00.000Z",
    "lastError": null,
    "secretName": "OpenAI key",
    "models": [
      { "id": "gpt-6.1-sol", "name": "GPT-6.1 Sol", "status": "available", "code": null, "ownKeyOnly": false },
      { "id": "gpt-6.1-terra", "name": "GPT-6.1 Terra", "status": "available", "code": null, "ownKeyOnly": false },
      { "id": "gpt-6-luna", "name": "GPT-6 Luna", "status": "unavailable", "code": "MODEL_OR_DEPLOYMENT_NOT_FOUND", "ownKeyOnly": false }
    ]
  }
}

If the key does not work, the response is also 200: status is invalid, lastError says why, and message is Key saved, but it does not work: see lastError.

Errors

Statusdetails.codeWhen it happens
400INVALID_PROVIDER{provider} is not one of the four
400INVALID_REQUESTvalue is missing, empty, or over 4,096 characters, fallback is neither platform nor none, or the body has an unknown field. details.issues says which, without repeating the key
403FORBIDDENThe person behind the token cannot manage and use secrets
429VERIFICATION_RATE_LIMITEDThere were already 10 tests of that provider in the last hour
503VERIFICATION_FAILEDThe key could not be tested with the provider. Get the provider before retrying

Notes

  • The test spends a few tokens from your provider account and can take a while: wait for the response for up to 200 seconds.
  • The key is stored as a workspace secret named, for example, OpenAI key. Replacing it stores the new one, removes the authorization of the previous one, and deletes it from Secrets. If you renamed the previous one or another integration uses it, it stays in Secrets.
  • To test it again without sending it, use test an AI provider key.