跳转到主要内容
API 参考文档目前仅提供英文版本。如果您正在查看其他语言版本的此页面,请切换到英文版本 — 完整的 API 端点列表将显示在左侧边栏中。
FIM One 提供 REST API,用于以编程方式访问 AI 智能体、对话、知识库等。

基础 URL

身份验证

所有 API 请求都需要通过 API 密钥或 JWT 令牌进行身份验证。

使用 API 密钥

在 Authorization 标头中包含您的 API 密钥:

Using JWT Token

The SSE streaming endpoints (/api/react, /api/dag and /api/auto) read the token from the request body, not from the Authorization header. The value can be a JWT access token or an API key:
See Authentication for detailed setup instructions.

响应格式

Success Response

Most endpoints that return a single resource or an acknowledgement wrap it in this structure (list endpoints and the sign-in endpoints return their payload directly):

Error Response

Error responses carry a human-readable detail, a machine-readable error_code (null for a few generic errors), and error_args with values for the message:

分页响应

列表端点返回分页结果:

Streaming (Server-Sent Events)

Chat endpoints (POST /api/react, POST /api/dag and POST /api/auto) return Server-Sent Events for real-time streaming. Each event has a type field indicating its content: The conversation title is generated in the background after end; read it from GET /api/conversations/{id}.

Example SSE Stream

Cursor-based resume

Every persisted SSE event is sent as {"cursor": <int>, "data": {...}}; the cursor increases monotonically within the assistant turn. Clients should track the highest cursor seen. When the connection drops mid-turn (network error, proxy timeout, server restart), the client can re-subscribe without re-running the agent:
The response is an SSE stream that replays cached events with cursor > 42 and ends with a terminal event: resume_done frame. Pass cursor: -1 to request a full replay from the beginning. Error responses:
  • 404 conversation_not_found — conversation id is invalid or not owned by the authenticated user
  • 404 no_recent_assistant_message — conversation has no persisted assistant turn to resume from (e.g., a brand-new conversation with no user messages yet)
  • 400 invalid_cursor — cursor is not a non-negative integer or -1
The reference frontend implementation (useSseResume hook in the playground) auto-retries network disconnects with exponential backoff (300ms → 1s → 3s, max 3 attempts) and distinguishes user-initiated abort from network error to avoid unintended reconnects. See the playground-page.tsx integration for the full pattern.
Resume is stateless — it replays from the assistant message’s stored sse_events array. If the agent’s turn was interrupted before any assistant message was persisted (e.g., a crash before done), the dangling tool_use block is auto-repaired by DbMemory._repair_dangling_tool_calls on the next turn. Synthetic tool_result rows are persisted with metadata_.synthetic=true and metadata_.reason="interrupted" for audit.

Business References

A system that embeds FIM One can tag each conversation with the id of the business object it is about, such as a contract number or a ticket id, and later reopen the latest conversation for that object.
  • business_ref is optional text. It is normalized to Unicode NFC, then surrounding whitespace is trimmed; an empty value means no reference. A value longer than 200 characters after normalization, or one containing control characters (C0 or C1), zero-width or other format characters, or the line and paragraph separators U+2028 and U+2029, is refused with 422 (invalid_business_ref for query parameters). The value is otherwise stored as given: it is not unique, not interpreted, and never passed to the model.
  • Filters and lookups match exactly and case-sensitively, after the same NFC normalization: HT-1 does not find ht-1, while a reference sent in decomposed form finds the one stored in composed form.
  • A reference belongs to the conversation’s owner. Filters and lookups only ever consider the caller’s own conversations, and administrator lists and exports do not show it. The administrators’ full backup (GET /api/admin/export/full-backup) leaves it out, so anything rebuilt from that backup has no references. The owner’s data export (GET /api/auth/me/export) includes it.
GET /api/conversations/latest orders by the newest message, falling back to the creation time, and considers active conversations unless status=archived is given. The list keeps its own order (starred first, then newest created).

速率限制

计划在未来版本中实现按密钥的速率限制。目前没有强制的按密钥请求限制,但请负责任地使用 API。

分页

列表端点支持通过查询参数进行分页:
参数:
  • page(默认值:1)— 页码,从 1 开始
  • size(默认值:20)— 每页项目数,最多 100

时间戳

所有时间戳均采用 ISO 8601 格式,使用 UTC 时区:

Error Codes

Common error codes and their meanings: Errors raised by the authentication layer for a bad Authorization header (Invalid token, Token has expired, Invalid API key, API key is disabled) return 401 with error_code: null; rely on the status code and detail for those. Request validation failures return 422.

API 游乐场

每个端点页面都包含一个交互式 API 游乐场,您可以:
  • 直接从浏览器测试请求
  • 查看真实响应
  • 复制多种语言的请求代码
  • 使用您的 API 密钥进行身份验证
API 游乐场从您的浏览器运行请求,因此请确保您的 API 密钥具有适当的 CORS 权限(通常对同源请求默认启用)。

SDK 可用性

虽然 FIM One API 完全基于 REST,但流行语言的 SDK 已可用(或即将推出):
  • Python:即将推出
  • JavaScript/TypeScript:即将推出
  • Go:即将推出

Versioning

The API carries the application version, reported by GET /api/version. Version is not included in the URL path; breaking changes will be signaled through major version bumps and a migration period.

支持

如有 API 问题或疑问: