document/content/openapi/intro.en.mdx
Starting with 4.15.0, FastGPT API docs are generated with zod-openapi. Some legacy endpoints have not been migrated yet, so they may not appear in the generated docs. Visit the generated API documentation URL to view the latest endpoint details. The manually maintained endpoint descriptions in the left-hand documentation are no longer updated.
FastGPT provides two generated API documents:
Use your FastGPT endpoint as the base URL and append the path below:
{{endpoint}}/apidoc/devapi{{endpoint}}/apidoc/systemopenapiDev API:
System OpenAPI:
FastGPT OpenAPI lets you authenticate with an API Key to access FastGPT services and resources -- such as calling app chat endpoints, uploading knowledge base data, search testing, and more. For compatibility and security reasons, not all endpoints support API Key access.
Note: BaseURL is not an endpoint address -- it's the root URL for all endpoints. Requesting the BaseURL directly won't work.
FastGPT uses a unified API Key model. API Keys are member credentials and are not bound to a single app.
chat/completions, pass appId explicitly in the request body or query.chat/completions, passing body.appId is recommended.Authorization: Bearer <apiKey>-<appId> is also supported for chat/completions. The -<appId> suffix is only a transport compatibility format and is not stored.authProxy on an API Key to let chat/completions run as another team member. This does not skip app or chat permission checks.In OpenAPI, all endpoints authenticate via Header.Authorization.
baseUrl: "http://localhost:3000/api"
headers: {
Authorization: "Bearer {{apikey}}"
}
Example: Start an App Chat
curl --location --request POST 'http://localhost:3000/api/v1/chat/completions' \
--header 'Authorization: Bearer fastgpt-xxxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
"appId": "your_app_id",
"chatId": "111",
"stream": false,
"detail": false,
"messages": [
{
"content": "Who is the director",
"role": "user"
}
]
}'
Since v4.8.13, you can pass a custom user ID that will be saved in the chat history.
curl --location --request POST 'http://localhost:3000/api/v1/chat/completions' \
--header 'Authorization: Bearer fastgpt-xxxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
"appId": "your_app_id",
"chatId": "111",
"stream": false,
"detail": false,
"messages": [
{
"content": "Who is the director",
"role": "user"
}
],
"customUid": "xxxxxx"
}'
In the chat history, this record's user will be displayed as xxxxxx.