# Add a model provider connection for the Studio assistant

Stores an encrypted API key for this provider connection and enables the listed models. Pass `defaultModel` to make one of its models the installation default.

URL: /docs/reference/configuration/createAssistantConnection

```json
{"openapi":"3.0.3","info":{"title":"Postdot API","description":"The HTTP API for the lightweight, self-hosted Postdot publication orchestrator.","version":"0.1.0"},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"Postdot API key","description":"A user-owned Postdot API key sent as `Authorization: Bearer <token>`. Its project scope is limited by the creator’s current access."},"sessionCookie":{"type":"apiKey","in":"cookie","name":"better-auth.session_token","description":"The Better Auth email/password session cookie used by the web application."}},"schemas":{}},"security":[{"bearerAuth":[]},{"sessionCookie":[]}],"tags":[{"name":"System","description":"Service health and runtime information."},{"name":"Access","description":"Instance membership and invitations."},{"name":"Projects","description":"Project lifecycle and access."},{"name":"Channels","description":"Project publication destinations."},{"name":"Posts","description":"Source posts and publication creation."},{"name":"Publications","description":"Publication workflow operations."},{"name":"Taxonomy","description":"Project categories and publication tags."},{"name":"Media","description":"Project media assets and uploads."},{"name":"Settings","description":"Instance-level runtime configuration."},{"name":"Audit","description":"Project audit history."},{"name":"Notifications","description":"Signed-in user notification inboxes with optional project context."},{"name":"Analytics","description":"Provider-neutral publication and execution analytics."},{"name":"Provider Analytics","description":"Persisted provider-owned metric observations."},{"name":"Webhooks","description":"Project webhook subscriptions and delivery history."}],"paths":{"/api/settings/assistant/connections":{"post":{"operationId":"createAssistantConnection","summary":"Add a model provider connection for the Studio assistant","description":"Stores an encrypted API key for this provider connection and enables the listed models. Pass `defaultModel` to make one of its models the installation default.","tags":["Configuration"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["provider","models"],"properties":{"provider":{"type":"string","enum":["openai-compatible","openai","anthropic","google","openrouter"]},"label":{"type":"string","maxLength":80},"baseUrl":{"type":"string","maxLength":2048},"enabled":{"type":"boolean"},"models":{"type":"array","items":{"type":"object","required":["id"],"properties":{"id":{"type":"string","minLength":1,"maxLength":200},"note":{"type":"string","maxLength":120},"images":{"type":"boolean","description":"OpenAI-compatible servers only: the model accepts image input. Off by default; catalog providers use their catalog capability."}}},"maxItems":50,"description":"Enabled models on this provider connection. Each model has an ID, an optional short note and, on OpenAI-compatible servers, whether it accepts images."},"contextWindow":{"anyOf":[{"type":"integer","minimum":4000,"maximum":2000000},{"type":"null"}]},"apiKey":{"anyOf":[{"type":"string","minLength":1,"maxLength":4096},{"type":"null"}]},"defaultModel":{"type":"string","maxLength":200}}}},"application/x-www-form-urlencoded":{"schema":{"type":"object","required":["provider","models"],"properties":{"provider":{"type":"string","enum":["openai-compatible","openai","anthropic","google","openrouter"]},"label":{"type":"string","maxLength":80},"baseUrl":{"type":"string","maxLength":2048},"enabled":{"type":"boolean"},"models":{"type":"array","items":{"type":"object","required":["id"],"properties":{"id":{"type":"string","minLength":1,"maxLength":200},"note":{"type":"string","maxLength":120},"images":{"type":"boolean","description":"OpenAI-compatible servers only: the model accepts image input. Off by default; catalog providers use their catalog capability."}}},"maxItems":50,"description":"Enabled models on this provider connection. Each model has an ID, an optional short note and, on OpenAI-compatible servers, whether it accepts images."},"contextWindow":{"anyOf":[{"type":"integer","minimum":4000,"maximum":2000000},{"type":"null"}]},"apiKey":{"anyOf":[{"type":"string","minLength":1,"maxLength":4096},{"type":"null"}]},"defaultModel":{"type":"string","maxLength":200}}}},"multipart/form-data":{"schema":{"type":"object","required":["provider","models"],"properties":{"provider":{"type":"string","enum":["openai-compatible","openai","anthropic","google","openrouter"]},"label":{"type":"string","maxLength":80},"baseUrl":{"type":"string","maxLength":2048},"enabled":{"type":"boolean"},"models":{"type":"array","items":{"type":"object","required":["id"],"properties":{"id":{"type":"string","minLength":1,"maxLength":200},"note":{"type":"string","maxLength":120},"images":{"type":"boolean","description":"OpenAI-compatible servers only: the model accepts image input. Off by default; catalog providers use their catalog capability."}}},"maxItems":50,"description":"Enabled models on this provider connection. Each model has an ID, an optional short note and, on OpenAI-compatible servers, whether it accepts images."},"contextWindow":{"anyOf":[{"type":"integer","minimum":4000,"maximum":2000000},{"type":"null"}]},"apiKey":{"anyOf":[{"type":"string","minLength":1,"maxLength":4096},{"type":"null"}]},"defaultModel":{"type":"string","maxLength":200}}}}}},"responses":{"201":{"description":"Response for status 201","content":{"application/json":{"schema":{"type":"object","required":["connection","settings"],"properties":{"connection":{"type":"object","required":["id","provider","label","baseUrl","enabled","models","contextWindow","hasApiKey","conversationCount","createdAt","updatedAt"],"properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai-compatible","openai","anthropic","google","openrouter"]},"label":{"type":"string","maxLength":80},"baseUrl":{"type":"string","maxLength":2048},"enabled":{"type":"boolean"},"models":{"type":"array","items":{"type":"object","required":["id"],"properties":{"id":{"type":"string","minLength":1,"maxLength":200},"note":{"type":"string","maxLength":120},"images":{"type":"boolean","description":"OpenAI-compatible servers only: the model accepts image input. Off by default; catalog providers use their catalog capability."}}},"maxItems":50,"description":"Enabled models on this provider connection. Each model has an ID, an optional short note and, on OpenAI-compatible servers, whether it accepts images."},"contextWindow":{"anyOf":[{"type":"integer","minimum":4000,"maximum":2000000},{"type":"null"}]},"hasApiKey":{"type":"boolean"},"conversationCount":{"type":"integer","minimum":0},"createdAt":{"type":"integer"},"updatedAt":{"type":"integer"}}},"settings":{"type":"object","required":["enabled","defaultConnectionId","defaultModel","limits","connections","source","provider","baseUrl","model","models","contextWindow","hasApiKey","memory"],"properties":{"enabled":{"type":"boolean"},"defaultConnectionId":{"type":"string"},"defaultModel":{"type":"string"},"limits":{"type":"object","required":["maxRunning","maxTurns","answerTimeoutSeconds","retentionDays"],"properties":{"maxRunning":{"type":"integer","minimum":1,"maximum":50},"maxTurns":{"type":"integer","minimum":1,"maximum":50},"answerTimeoutSeconds":{"type":"integer","minimum":10,"maximum":900},"retentionDays":{"type":"integer","minimum":1,"maximum":3650}}},"connections":{"type":"array","items":{"type":"object","required":["id","provider","label","baseUrl","enabled","models","contextWindow","hasApiKey","conversationCount","createdAt","updatedAt"],"properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai-compatible","openai","anthropic","google","openrouter"]},"label":{"type":"string","maxLength":80},"baseUrl":{"type":"string","maxLength":2048},"enabled":{"type":"boolean"},"models":{"type":"array","items":{"type":"object","required":["id"],"properties":{"id":{"type":"string","minLength":1,"maxLength":200},"note":{"type":"string","maxLength":120},"images":{"type":"boolean","description":"OpenAI-compatible servers only: the model accepts image input. Off by default; catalog providers use their catalog capability."}}},"maxItems":50,"description":"Enabled models on this provider connection. Each model has an ID, an optional short note and, on OpenAI-compatible servers, whether it accepts images."},"contextWindow":{"anyOf":[{"type":"integer","minimum":4000,"maximum":2000000},{"type":"null"}]},"hasApiKey":{"type":"boolean"},"conversationCount":{"type":"integer","minimum":0},"createdAt":{"type":"integer"},"updatedAt":{"type":"integer"}}}},"source":{"type":"string","enum":["database","deployment","none"]},"provider":{"type":"string","enum":["openai-compatible","openai","anthropic","google","openrouter"]},"baseUrl":{"type":"string","maxLength":2048},"model":{"type":"string","maxLength":200},"models":{"type":"array","items":{"type":"object","required":["id"],"properties":{"id":{"type":"string","minLength":1,"maxLength":200},"note":{"type":"string","maxLength":120},"images":{"type":"boolean","description":"OpenAI-compatible servers only: the model accepts image input. Off by default; catalog providers use their catalog capability."}}},"maxItems":50,"description":"Enabled models on this provider connection. Each model has an ID, an optional short note and, on OpenAI-compatible servers, whether it accepts images."},"contextWindow":{"anyOf":[{"type":"integer","minimum":4000,"maximum":2000000},{"type":"null"}]},"hasApiKey":{"type":"boolean"},"memory":{"type":"object","required":["enabled","maxEntriesAllProjects","maxEntriesPerProject","maxCharactersAllProjects","maxCharactersPerProject","entryCount"],"properties":{"enabled":{"type":"boolean"},"maxEntriesAllProjects":{"type":"integer","minimum":5,"maximum":50},"maxEntriesPerProject":{"type":"integer","minimum":5,"maximum":50},"maxCharactersAllProjects":{"type":"integer","minimum":400,"maximum":4000},"maxCharactersPerProject":{"type":"integer","minimum":400,"maximum":4000},"entryCount":{"type":"integer","minimum":0}}}}}}}}}},"400":{"description":"Response for status 400","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","enum":["assistant_missing_fields","assistant_invalid_base_url","assistant_missing_api_key","assistant_too_many_connections"]},"message":{"type":"string"}}}}}}}},"401":{"description":"Response for status 401","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"confirmation":{"type":"string"},"warnings":{"type":"array","items":{"type":"object","required":["channelId","rule","period","maximum","count"],"properties":{"channelId":{"type":"string"},"rule":{"type":"string","enum":["daily_max","weekly_max"]},"period":{"type":"string"},"maximum":{"type":"integer"},"count":{"type":"integer"}}}},"code":{"type":"string"},"message":{"type":"string"},"publicationIds":{"type":"array","items":{"type":"string"}}}}}}}}},"403":{"description":"Response for status 403","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"confirmation":{"type":"string"},"warnings":{"type":"array","items":{"type":"object","required":["channelId","rule","period","maximum","count"],"properties":{"channelId":{"type":"string"},"rule":{"type":"string","enum":["daily_max","weekly_max"]},"period":{"type":"string"},"maximum":{"type":"integer"},"count":{"type":"integer"}}}},"code":{"type":"string"},"message":{"type":"string"},"publicationIds":{"type":"array","items":{"type":"string"}}}}}}}}},"503":{"description":"Response for status 503","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"confirmation":{"type":"string"},"warnings":{"type":"array","items":{"type":"object","required":["channelId","rule","period","maximum","count"],"properties":{"channelId":{"type":"string"},"rule":{"type":"string","enum":["daily_max","weekly_max"]},"period":{"type":"string"},"maximum":{"type":"integer"},"count":{"type":"integer"}}}},"code":{"type":"string"},"message":{"type":"string"},"publicationIds":{"type":"array","items":{"type":"string"}}}}}}}}}}}}},"servers":[{"url":"https://postdot.example","description":"Replace with your Postdot instance origin."}]}
```
