mirror of
https://github.com/labring/FastGPT.git
synced 2026-02-28 01:02:28 +08:00
* docs(i18n): translate batch 1 * docs(i18n): translate batch 2 * docs(i18n): translate batch 3 (20 files) - openapi/: app, share - faq/: all 8 files - use-cases/: index, external-integration (5 files), app-cases (4 files) Translated using North American style with natural, concise language. Preserved MDX syntax, code blocks, images, and component imports. * docs(i18n): translate protocol docs * docs(i18n): translate introduction docs (part 1) * docs(i18n): translate use-cases docs * docs(i18n): translate introduction docs (part 2 - batch 1) * docs(i18n): translate final 9 files * fix(i18n): fix YAML and MDX syntax errors in translated files - Add quotes to description with colon in submit_application_template.en.mdx - Remove duplicate Chinese content in translate-subtitle-using-gpt.en.mdx - Fix unclosed details tag issue * docs(i18n): translate all meta.json navigation files * fix(i18n): translate Chinese separators in meta.en.json files * translate * translate * i18n --------- Co-authored-by: archer <archer@archerdeMac-mini.local> Co-authored-by: archer <545436317@qq.com>
89 lines
2.6 KiB
Plaintext
89 lines
2.6 KiB
Plaintext
---
|
|
title: OpenAPI Introduction
|
|
description: FastGPT OpenAPI Introduction
|
|
---
|
|
|
|
## Automated API Documentation
|
|
|
|
The automated API documentation covers all endpoints in the current version, regardless of whether they can be called via API Key.
|
|
|
|
All future endpoints will be auto-generated, with documentation continuously improved.
|
|
|
|
- [China Mainland API Documentation](https://cloud.fastgpt.cn/openapi)
|
|
- [International API Documentation](https://cloud.fastgpt.io/openapi)
|
|
|
|
## Usage Guide
|
|
|
|
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.
|
|
|
|
## How to Find Your BaseURL
|
|
|
|
**Note: BaseURL is not an endpoint address -- it's the root URL for all endpoints. Requesting the BaseURL directly won't work.**
|
|
|
|

|
|
|
|
## How to Get an API Key
|
|
|
|
FastGPT has **2 types** of API Keys: a global key (cannot directly call app chat) and an app-specific key that includes an AppId (can directly call app chat).
|
|
|
|
We recommend using `app-specific keys` only for app or chat-related endpoints, and `global keys` for everything else.
|
|
|
|
| Global Key | App-Specific Key |
|
|
| --------------------- | --------------------- |
|
|
|  |  |
|
|
|
|
|
|
## Basic Configuration
|
|
|
|
In OpenAPI, all endpoints authenticate via Header.Authorization.
|
|
|
|
```
|
|
baseUrl: "http://localhost:3000/api"
|
|
headers: {
|
|
Authorization: "Bearer {{apikey}}"
|
|
}
|
|
```
|
|
|
|
**Example: Start an App Chat**
|
|
|
|
```sh
|
|
curl --location --request POST 'http://localhost:3000/api/v1/chat/completions' \
|
|
--header 'Authorization: Bearer fastgpt-xxxxxx' \
|
|
--header 'Content-Type: application/json' \
|
|
--data-raw '{
|
|
"chatId": "111",
|
|
"stream": false,
|
|
"detail": false,
|
|
"messages": [
|
|
{
|
|
"content": "Who is the director",
|
|
"role": "user"
|
|
}
|
|
]
|
|
}'
|
|
```
|
|
|
|
## Custom User ID
|
|
|
|
Since `v4.8.13`, you can pass a custom user ID that will be saved in the chat history.
|
|
|
|
```sh
|
|
curl --location --request POST 'http://localhost:3000/api/v1/chat/completions' \
|
|
--header 'Authorization: Bearer fastgpt-xxxxxx' \
|
|
--header 'Content-Type: application/json' \
|
|
--data-raw '{
|
|
"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`.
|