StarModel 邀请活动
← 返回 Skill 列表
extension
分类: 开发与工程API Key 暂未确认

devic-api

Devic AI平台API参考,适用于助手、代理和服务端工具。在使用Devic API端点、创建集成或构建与Devic平台交互的应用程序时使用。

person作者: jakexiaohubgithub

Devic API

Devic is an AI platform that enables developers to build, deploy, and manage AI-powered assistants and autonomous agents. The platform provides a comprehensive REST API for programmatic access to all platform features.

Base URL

https://api.devic.ai

Authentication

All API requests require authentication using a JWT Bearer token. API keys follow the pattern. Generate your API key from the Devic dashboard on https://app.devic.ai/api-keys:

devic-{random_string}

Example: devic-wengpqengqp1234abcd

Request Header

Include the API key in the Authorization header:

Authorization: Bearer devic-your-api-key-here

Credentials that reach a browser

An API key states which account is calling, never which of your customers. Anywhere the key can be read — a bundle, a mobile app — the tenant beside it is a claim anyone can edit. For those, mint a tenant session on your server and send that as the bearer token instead: it carries the tenant in a signed claim and is imposed on every query. A key can also be restricted to signed mode, in which minting sessions is the only thing it can do. See tenant-sessions.md.

Example Request

curl -X GET "https://api.devic.ai/api/v1/assistants" \
  -H "Authorization: Bearer devic-your-api-key-here" \
  -H "Content-Type: application/json"

Response Format

All API responses follow a standardized format:

Success Response

{
  "success": true,
  "data": { ... },
  "meta": { "timestamp": "2024-01-15T10:30:00.000Z", "duration": "42ms" }
}

A handler result that already has a top-level success or error key is returned as is, without the wrapper (for example { "success": true, "message": "Tool server deleted" }).

Error Responses

Errors come in three shapes. Check the HTTP status and the presence of an error key:

  1. Error with a code. The HTTP status is 4xx/5xx and the body carries a code:
    { "error": "CHAT_BUSY", "message": "The conversation is processing a previous message" }
    
    Some carry extra fields, for example the usage-limit 429 (details, retryAfter) or the deprecated-model 410 (replacementModel).
  2. Plain HTTP error. The HTTP status is 4xx/5xx and the body uses the framework format, where error is the status name, not a code:
    { "statusCode": 404, "message": "Tool server not found", "error": "Not Found" }
    
  3. Failure reported with a success status. Some endpoints answer 200/201 with a body such as { "error": "THREAD_CANNOT_BE_MANUALLY_COMPLETED" }. Each file lists where this happens.

Architecture Overview

Understanding how the core entities relate to each other is essential for building integrations with the Devic platform.

Entity Relationships

┌─────────────────────────────────────────────────────────────────┐
│                         Tool Server                             │
│  (External API integration with tool definitions)               │
└─────────────────────────────────────────────────────────────────┘
                              │
                              │ referenced by
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│                       Tools Group                               │
│  (Logical grouping of tools - built-in or from tool server)     │
└─────────────────────────────────────────────────────────────────┘
                              │
                              │ availableToolsGroupsUids
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│              Assistant Specialization                           │
│  (Configuration: presets, tools, model, provider, etc.)         │
└─────────────────────────────────────────────────────────────────┘
                    /                   \
                   /                     \
                  ▼                       ▼
┌──────────────────────┐     ┌──────────────────────────────────┐
│     Assistant        │     │            Agent                  │
│  (Chat interface)    │     │  (Autonomous execution threads)   │
└──────────────────────┘     └──────────────────────────────────┘
         │                              │           │
         ▼                              ▼           │ hand_off_subagent
┌──────────────────────┐     ┌──────────────────────┴───────────┐
│   Chat Histories     │     │          Threads                  │
│  (Conversations)     │     │  (Execution sessions with tasks)  │
└──────────────────────┘     │                                   │
                              │  ┌─────────────────────────────┐ │
                              │  │  Subthreads                  │ │
                              │  │  (Child executions from      │ │
                              │  │   subagent handoffs)         │ │
                              │  └─────────────────────────────┘ │
                              └──────────────────────────────────┘

Key Concepts

Assistant Specialization: The core configuration object that defines how an AI assistant or agent behaves. It includes:

  • presets - System prompt instructions. May contain {{placeholder}} variables that are filled at request time via metadata.promptTemplateParams (see assistants.md and agents.md)
  • availableToolsGroupsUids - Array of tool group identifiers that determine available tools
  • enabledTools - Optional allowlist of tool identifiers across the assigned groups and the attached code snippets. null (or absent) enables every tool, [] enables none. On a partial update, omit it to leave the current selection untouched
  • codeSnippetIds - Code snippets the entity can call as tools. With an enabledTools list, each snippet's toolName has to be in it
  • model / provider - Default LLM configuration
  • memoryDocuments - Persistent context documents

Agents: Autonomous executors that use an embedded assistantSpecialization configuration. When you create an agent, you configure its specialization which determines:

  • What tools it can use (via availableToolsGroupsUids)
  • How it behaves (via presets)
  • What LLM powers it (via model/provider)

Tool Servers: External API integrations that define tools. A tool server:

  1. Is created via the Tool Servers API
  2. Gets assigned to a Tools Group
  3. The group's UID is added to an assistant/agent's availableToolsGroupsUids
  4. The tools become available for that assistant/agent to use

Workflow Example

To give an agent access to a custom CRM API:

  1. Create Tool Server with your CRM endpoint definitions
  2. Create/Configure a Tools Group that references the tool server (done via Devic dashboard)
  3. Update the Agent's assistantSpecialization to include the tools group UID in availableToolsGroupsUids
  4. The agent can now call CRM tools during execution

Conversation names and reasoning

For chatName, assistant/conversation/message reasoningEffort, resets and model-compatible levels from GET /api/v1/models, read conversation-options.md. Keep conversation naming separate from the assistant's own name.

API Sections

The Devic API is organized into three main sections:

1. Assistants API

Manage AI assistants that can process messages and maintain conversation history.

  • Create, update, and delete assistant specializations
  • List and retrieve assistant specializations
  • Send messages to assistants
  • Manage chat histories

Base path: /api/v1/assistants

For detailed documentation, see assistants.md.

2. Agents API

Manage autonomous agents that can execute multi-step tasks with tool access.

  • Create and manage agent execution threads
  • Handle approval workflows
  • Pause, resume, and complete agent executions
  • Evaluate agent performance
  • Track agent costs
  • Run an agent on a schedule (periodicExecution: cron, a time of day, or every N days) — no external scheduler needed
  • Connect an agent to an Environment (environmentId)

Base path: /api/v1/agents

For detailed documentation, see agents.md.

3. Tool Servers API

Configure external tool integrations that agents and assistants can use.

  • Create and manage tool servers
  • Define tool specifications
  • Test tool configurations
  • Clone tool servers

Base path: /api/v1/tool-servers

For detailed documentation, see tool-servers.md.

4. Files API

Upload files and get shareable download URLs. Used for attaching files to assistant messages.

  • Upload files via multipart/form-data
  • Get download URLs for uploaded files

Base path: /api/v1/files

For detailed documentation, see files.md.

5. Feedback API

Collect user feedback on AI responses from both assistants and agents.

  • Submit feedback (positive/negative) on chat messages
  • Submit feedback on agent thread messages
  • Retrieve feedback history for chats and threads
  • Support for structured feedback data (ratings, categories, etc.)

Base paths:

  • Chat feedback: /api/v1/assistants/:identifier/chats/:chatUid/feedback
  • Thread feedback: /api/v1/agents/threads/:threadId/feedback

For detailed documentation, see feedback.md.

6. Whisper API (Speech-to-Text)

Transcribe audio to text using OpenAI Whisper with Devic's own OpenAI key.

  • Transcribe an audio binary (multipart) or a download URL
  • Optional language hint, message and chat linkage
  • Returns a transcriptId to attach to the resulting assistant message

Base path: /api/v1/whisper

For detailed documentation, see whisper.md.

7. Tenants API

Manage the tenants and subtenants of your account for multi-tenant products, read aggregated cost/usage, and enforce usage limits (token/cost caps) with reusable tiers (plans).

  • Auto-register tenants/subtenants by passing tenantId/subtenantId on messages and threads
  • List/update/delete tenants and subtenants
  • Read per-tenant cost time series and live chat/thread stats
  • Read usage limits, current consumption and durable history (read-only, devic-ui preset)
  • Reset counters and change tier from billing/checkout webhooks (full keys only)
  • Usage limits block execution with HTTP 429 TENANT_LIMIT_EXCEEDED

Base paths: /api/v1/tenants · /api/v1/tenant-usage · /api/v1/tenant-admin

For detailed documentation, see tenants.md.

8. Documents & Skills API

Manage the knowledge your assistants and agents read at runtime, and the skills built on top of it.

  • Create, version and organise markdown documents and folders
  • Attach documents or folders to an assistant, an agent or an environment
  • Publish a document or folder as a skill: its name and description go into the system prompt and the model loads the full instructions on demand
  • Scaffold a folder-skill (folder + SKILL.md) in one call, browse the skills catalog, download a skill tree
  • Skills are documents and folders: there is no /api/v1/skills. Create and edit them through /api/v1/documents and /api/v1/document-folders; the skill routes live under /api/v1/documents/skills

Base paths: /api/v1/documents · /api/v1/document-folders

For detailed documentation, see documents.md.

9. Tenant Sessions API

Short-lived tokens that prove which of your customers is calling, for credentials that end up in a browser. Your backend mints one from your own login; the page then carries the session instead of an API key.

  • Mint a session for a tenant/subtenant, with a lifetime you choose (1 h by default, 12 h max)
  • A session reaches only what an end user does — chatting, its own conversations, attachments, its own limits, its own connected apps
  • The identity in the token is imposed on path, query and body, so another tenant cannot be reached by editing a request
  • An API key can be put in signed mode, where minting sessions is the only thing it can do

Base path: /api/v1/tenant-sessions

For detailed documentation, see tenant-sessions.md.

10. Built-in Tools Reference

List of all built-in tool groups with their UIDs, ready to use in availableToolsGroupsUids.

For detailed documentation, see built-in-tools.md.

11. Channels API

Attach the places your customers already write from — a WhatsApp number, a Slack workspace — to the tenants you already have.

  • Issue a link that ties a channel identity to one of your tenants; the tenant is frozen into the link and never read from a request
  • WhatsApp needs no consent screen: the link opens a chat with a short code already written, and that first message is the consent
  • Read what you have issued and whether anybody used it; withdraw a link without unmapping what it already bound
  • Read the directory: which workspace, number or person belongs to which customer, and who is talking without an owner yet

Base path: /api/v1/channels

For detailed documentation, see channels.md.

12. Environments & Sandboxes API

The machine an agent works on and everything it may reach.

  • Create environments: sandbox runtime, init script, knowledge, tools
  • Store credentials as environment variables, encrypted at rest and injected into the machine — not passed through a message, where they would be stored and readable back indefinitely
  • Bake snapshots, including one per tenant
  • Connect agents and assistants to an environment
  • Start a real Linux machine, run shell on it, read and write its files

Base path: /api/v1/environments

For detailed documentation, see environments.md.

13. Code Snippets API

Functions you write once and give to agents and assistants as tools.

  • Create snippets in JavaScript, TypeScript or Python: a main(input) function plus the JSON Schema of input
  • Every change to the code or the contract saves a version; expectedVersion refuses stale overwrites with 409
  • Run a saved snippet in an isolated sandbox with your inputs or its saved test cases
  • Attach one to an agent or assistant by listing its id in codeSnippetIds

Base path: /api/v1/code-snippets

For detailed documentation, see code-snippets.md.

14. Projects API

Group agents, assistants, documents, tool servers and environments under a project, and read what happened inside it.

  • Create, list, update and archive projects (identifier is unique and immutable; visibility is private or public)
  • DELETE archives a project; PATCH { "archived": false } restores it
  • Read a project's agent threads and assistant conversations
  • Read its current-month stats and its daily/monthly cost records, optionally narrowed to one tenant

Base path: /api/v1/projects

For detailed documentation, see projects.md.

15. Integrations & Triggers API

Connect third-party apps (Gmail, Drive, HubSpot, …) and start agents or assistants from their events.

  • Browse the app catalogue and each app's event types
  • Connect an account: API-key apps in one call, OAuth apps through an authorizationUrl; missing credentials answer INTEGRATION_SETUP_REQUIRED with the fields to send
  • Build an integration tool server from the connected account, choose which of the app's tools it exposes, and test a tool against the real account
  • Create triggers that start an agent (agentId) or an assistant (assistantId, its identifier) on each event, with message templates, rate limits and a delivery log

Base paths: /api/v1/integrations · /api/v1/triggers

For detailed documentation, see integrations.md.

16. Workspaces API

Shared spaces where people and assistants work in threads.

  • List and search workspaces and threads, including only the unread ones, with pagination
  • Read a thread by pages and write messages; the server records who wrote them and through what channel (api, cli, sdk)
  • Answer an assistant's questions, approve, cancel or retry its runs
  • Download the files of a thread and list every document of a workspace
  • Configure everything: settings, members, assistants, knowledge and skills, rules, core memory and automations
  • Build automations without the in-app designer: discover destinations, accounts, app events and tools, connect a missing app through an authorization link, save a validated draft
  • Same permissions as the apps. An API key acts for a person with X-Devic-User, or as the account integration ("API") without it

Base path: /api/v1/workspaces

For detailed documentation, see workspaces.md. For task recipes (identity, unread inbox, answering and approving runs, CLI equivalents) see the standalone devic-workspaces skill.

Building an automation (app event, schedule or on demand) for someone, from an MCP client or the API: follow workspace-automations.md, a step-by-step recipe from inventory to a draft the person activates.

Pagination

List endpoints support pagination with the following query parameters:

| Parameter | Type | Default | Max | Description | |-----------|------|---------|-----|-------------| | offset | number | 0 | - | Number of items to skip | | limit | number | 10 | 100 | Maximum items to return |

Paginated responses include metadata:

{
  "data": [...],
  "total": 50,
  "offset": 0,
  "limit": 10,
  "hasMore": true
}

Rate Limits

API rate limits are applied per API key. Contact support for rate limit details specific to your plan.

Common HTTP Status Codes

| Code | Description | |------|-------------| | 200 | Success | | 201 | Created | | 400 | Bad Request - Invalid input data | | 401 | Unauthorized - Invalid or missing API key; also a route a tenant session may not call, or a signed key used without a session (see tenant-sessions.md) | | 403 | Forbidden - The credential proved one identity and the request asked for another (tenant sessions) | | 404 | Not Found - Resource does not exist | | 429 | Too Many Requests - Rate limit, or tenant usage limit (TENANT_LIMIT_EXCEEDED, see tenants.md) | | 500 | Internal Server Error |

Quick Start Examples

Create an assistant

curl -X POST "https://api.devic.ai/api/v1/assistants" \
  -H "Authorization: Bearer devic-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Assistant",
    "description": "A helpful assistant",
    "model": "gpt-4.1-mini",
    "provider": "openai"
  }'

Send a message to an assistant

curl -X POST "https://api.devic.ai/api/v1/assistants/default/messages" \
  -H "Authorization: Bearer devic-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Hello, how can you help me?",
    "chatUid": "optional-chat-id"
  }'

Create an agent thread

curl -X POST "https://api.devic.ai/api/v1/agents/{agentId}/threads" \
  -H "Authorization: Bearer devic-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Analyze the sales data and create a report"
  }'

List tool servers

curl -X GET "https://api.devic.ai/api/v1/tool-servers?limit=10" \
  -H "Authorization: Bearer devic-your-api-key"