Administrator AI Search Integration API
See Integrations Overview for the shared list endpoint and other integration references.
Base URL: http://localhost:8000/api/v1
Prefix: /admins/platform-settings/integrations
Auth: Administrator JWT required
Headers: Content-Type: application/json
1. Get AI Search Configuration
Retrieve the saved integration state without exposing provider credentials.
GET
/admins/platform-settings/integrations/ai_search/Auth: Required
Headers
Authorization: Bearer {{admin_access_token}}Success Example
{
"success": true,
"message": "Integration retrieved successfully.",
"data": {
"integration": {
"type": "ai_search",
"is_enabled": false,
"configured": false,
"config": {
"has_openai_api_key": false,
"has_anthropic_api_key": false,
"has_gemini_api_key": false
},
"updated_at": "2026-10-09T10:00:00Z"
}
}
}Notes
- Requires an active administrator account. Customers and sellers cannot manage integration configuration.
- The example shows a newly created integration. Configured provider/model fields are included when saved, but API keys are replaced with
has_*_api_keyflags. configuredmeans encrypted configuration exists, not that credentials have been verified or that provider access works. The flags describe saved keys, not environment fallback keys.- This GET creates a disabled integration when none exists, following the existing integration API behavior. The integrations list endpoint also creates missing integration rows. Once a row exists, its
is_enabledvalue overridesAI_SEARCH_ENABLED. - Applicable errors:
401missing/invalid/expired JWT;403authenticated account is not an active administrator;405unsupported HTTP method;406unsupported response format.
2. Update AI Search Configuration
Select the provider, save credentials and model IDs, and enable or disable AI search.
PATCH
/admins/platform-settings/integrations/ai_search/Auth: Required
Headers
Authorization: Bearer {{admin_access_token}}Request Body
{
"is_enabled": true,
"config": {
"provider": "openai",
"openai_api_key": "replace-with-your-api-key",
"openai_model": "gpt-4.1-mini"
}
}Success Example
{
"success": true,
"message": "Integration updated successfully.",
"data": {
"integration": {
"type": "ai_search",
"is_enabled": true,
"configured": true,
"config": {
"provider": "openai",
"openai_model": "gpt-4.1-mini",
"has_openai_api_key": true,
"has_anthropic_api_key": false,
"has_gemini_api_key": false
},
"updated_at": "2026-10-09T10:05:00Z"
}
}
}Notes
- Replace the example API key with your provider credential and choose a structured-output-compatible model available to your account. Configuration validation checks required values; it does not make a billable provider call.
- Supported providers are
openai,anthropic, andgemini. Credentials and models useopenai_api_key/openai_model,anthropic_api_key/anthropic_model, andgemini_api_key/gemini_model. - All three providers may be configured together. Only the selected provider is called, and changing
providerpreserves the other providers' credentials. Model IDs accept letters, digits, dots, underscores, and hyphens, up to 200 characters. Unknown config fields, including custom provider URLs, are rejected. - Enabling requires the selected provider's key and model, from saved config or the corresponding
AI_SEARCH_*environment fallback. Models must support the adapter's structured-output API: OpenAI Responses, Anthropic Messages, or Gemini GenerateContent. There is no default model. - Updates merge with saved config. Omitted values are retained; explicit empty key/model strings clear those values and block environment fallback. Disable the integration before clearing required values.
- API keys remain encrypted using Fernet and are never returned in API responses. Protect
PLATFORM_CONFIG_ENCRYPTION_KEY, which falls back to Django'sSECRET_KEY, and keep it stable so existing configuration remains decryptable. Use HTTPS in production. - In the admin interface, only the selected provider's model and key fields are shown. Switching providers preserves unsaved field values until saving; saving submits only the selected provider's fields. A blank key input is omitted by the UI, preserving a saved key. API clients must omit the key field to preserve it; sending an empty string clears it.
- See Customer AI Search API for public search requests, pagination, rate limits, and provider failure responses.
- Applicable errors:
400malformed JSON, unknown config fields, invalid provider/model, or missing required enabled-provider configuration;401missing/invalid/expired JWT;403account is not an active administrator;405unsupported HTTP method;406unsupported response format;415unsupported request content type.
Common Success Format
{
"success": true,
"message": "Integration updated successfully.",
"data": {
"integration": {
"type": "ai_search",
"is_enabled": true,
"configured": true,
"config": {
"provider": "openai",
"openai_model": "gpt-4.1-mini",
"has_openai_api_key": true,
"has_anthropic_api_key": false,
"has_gemini_api_key": false
},
"updated_at": "2026-10-09T10:05:00Z"
}
}
}Common Error Format
HTTP 400 when enabling without the selected provider's required credentials:
{
"success": false,
"message": "Validation failed.",
"errors": {
"config": {
"openai_api_key": "This field is required when enabling the integration.",
"openai_model": "This field is required when enabling the integration."
}
}
}Errors with a single detail message return an empty errors object. For example, HTTP 401:
{
"success": false,
"message": "Authentication credentials were not provided.",
"errors": {}
}