Implemented on 2026-07-27.
Move the models discovery endpoint from the Social Media Tools extension scope to a primary OpenAI section, while maintaining backward compatibility with the existing social-media-tools endpoint.
GET /api/ai/modelsGET /api/social-media-tools/extension/models{
"models": ["gpt-4", "gpt-4o", ...],
"default_model": "gpt-4o",
"source": "live_discovery|configured_fallback",
"warning": "optional message"
}
Primary endpoint:
GET /api/ai/models
Behavior:
Keep existing endpoint:
GET /api/social-media-tools/extension/models
Implementation pattern:
/api/ai/models instead"/docs/en/ai/openai.md:## API: List available AI models
Endpoint:
- `GET /api/ai/models`
Purpose:
- returns the backend-discovered model list for the authenticated user or token
- allows any AI client to get available models without calling OpenAI directly
- reuses the same provider key resolution rules as the rest of Tools (personal OpenAI key if present, otherwise global)
### Authentication
- JWT/web user session
- bearer token with any AI-capable scope (`ai.socialgpt`, `ai.internal`, `ai.copilot`, etc.)
- admin users are always allowed
- non-admin users require at least one active personal API token or approved OpenAI access
### Response
JSON response includes:
- `models` *(array)* — available model identifiers suitable for chat completions
- `default_model` *(string)* — effective default model for this user/context
- `source` *(string)* — whether the list came from `live_discovery` or `configured_fallback`
- `warning` *(string, optional)* — fallback/discovery status message if applicable
### Example Request
```bash
curl -X GET "https://tools.tornevall.net/api/ai/models" \
-H "Authorization: Bearer YOUR_API_TOKEN"
{
"ok": true,
"models": ["gpt-4", "gpt-4-turbo", "gpt-4o", "gpt-4o-mini"],
"default_model": "gpt-4o",
"source": "live_discovery",
"warning": null
}
If live provider discovery fails:
source field indicates configured_fallbackwarning explains why fallback was used
2. **After adding the new section, add a "Legacy APIs" subsection** at the end of the OpenAI docs:
```markdown
## Legacy: Social Media Tools Model Catalog
The endpoint:
- `GET /api/social-media-tools/extension/models`
is now a **backward-compatible alias** to `GET /api/ai/models`.
For new integrations, use `/api/ai/models` instead.
This legacy route will continue to work indefinitely to avoid breaking existing Social Media Tools extensions.
Create controller method (or route/handler)
AiGatewayController or new ModelCatalogControllerGET /api/ai/modelsmodels, default_model, source, warningCreate or update route
routes/api.php: Route::get('/ai/models', ...)/api/social-media-tools/extension/models routeUpdate documentation
/docs/en/ai/openai.md/docs/sv/ai/openai.mdTesting
ai.socialgpt, ai.internal, etc.)/api/ai/models and /api/social-media-tools/extension/models return identical responsesBackward compatibility verification
Why this change:
/api/ai/internal/respond (other core AI endpoints)/api/ai/models?filter=chat in futureWhy maintain backward compatibility: