agentleFS
JayuanlabJayuanlab/zhiyu/skills/openzhiyu-api/SKILL.md

openzhiyu-api

Skill0 starsChanged 2 months agoApache-2.0View on GitHub

Zhiyu API documentation and reference. Use when working with Zhiyu backend APIs, AI, authentication, characters, messages, files, integrations, billing, or any server-side functionality. Triggers: API endpoints, backend routes, authentication, cloud API, integrations

  • Sends data out

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When running Zhiyu desktop app, the local API server runs on port 3414 (fallback: 3515):

    line 255
  2. Distinctive:

    Important: All authenticated requests require the token to be base64 decoded first.

    line 276

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Note: If you haven't downloaded or installed Zhiyu yet, please refer to Getting Started for installation instructions.

Zhiyu API Documentation

API Modules

Module Overview

ModuleBase PathDescription
Auth/api/auth/*, /api/remote-auth/*OAuth, login, register
User/api/user/*User identity and entitlements
Chat/api/chat/* (app routes)Chat/Character CRUD
Messages/api/messages/*Message sending and sync
Files/api/files/*File storage and upload
Storage/api/storage/*Session and disk management
Integrations/api/integrations/*, /api/*/callbackSlack, Discord, X, etc.
RAG/api/rag/*Retrieval-augmented generation
Workspace/api/workspace/*Artifacts and skills
Native/api/native/*Native agent operations
AI/api/ai/*LLM, embeddings, images, audio
Insights/api/insights/*, /api/chat-insights/*Analytics and insights
Billing/api/billing/*Billing ledger

Endpoints Reference

Auth Module (/api/auth/*, /api/remote-auth/*)

MethodEndpointDescription
POST/api/auth/poll-[provider]Poll OAuth status
POST/api/auth/set-tokenSet auth token
POST/api/auth/clear-auth-cookieClear session
POST/api/remote-auth/loginLogin with email/password
POST/api/remote-auth/registerRegister new user
POST/api/remote-auth/oauth/[provider]OAuth exchange
POST/api/remote-auth/oauth/[provider]/exchangeOAuth code exchange
POST/api/remote-auth/refreshRefresh token
GET/api/remote-auth/userGet current user
PUT/api/remote-auth/userUpdate user info
GET/api/remote-auth/subscriptionGet subscription info

Login Example

curl -X POST https://app.openzhiyu.ai/api/remote-auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","password":"password123"}'

Response:

{
  "user": { "id": "user_xxx", "email": "user@example.com", "name": "User" },
  "token": "eyJhbG..."
}

User Module (/api/user/*)

MethodEndpointDescription
GET/api/user/identityGet user identity
PUT/api/user/identityUpdate identity
PUT/api/user/passwordChange password
GET/api/user/entitlementsGet user entitlements

Messages Module (/api/messages/*)

MethodEndpointDescription
GET/api/messagesList messages
POST/api/messagesSend message
GET/api/messages/syncSync messages
GET/api/messages/checkCheck message status
GET/api/messages/rawGet raw message

Files Module (/api/files/*)

MethodEndpointDescription
GET/api/files/listList files
GET/api/files/[id]Get file by ID
POST/api/files/uploadUpload file
POST/api/files/saveSave file
GET/api/files/usageGet storage usage
GET/api/files/insights/downloadDownload insights file
POST/api/files/insights/saveSave insights

Storage Module (/api/storage/*)

MethodEndpointDescription
GET/api/storage/disk-usageGet disk usage
POST/api/storage/cleanupCleanup storage
GET/api/storage/sessionsList sessions
GET/api/storage/sessions/[taskId]Get session by task ID
DELETE/api/storage/sessions/[taskId]Delete session

Integrations Module (/api/integrations/*)

MethodEndpointDescription
GET/api/integrations/accountsList connected accounts
GET/api/integrations/slack/oauth/startStart Slack OAuth
GET/api/integrations/slack/oauth/exchangeExchange Slack OAuth code
GET/api/integrations/discord/oauth/startStart Discord OAuth
GET/api/integrations/discord/oauth/exchangeExchange Discord OAuth code
GET/api/integrations/x/oauth/startStart X OAuth

OAuth Callbacks (Various Platforms)

MethodEndpointPlatform
GET/api/slack/callbackSlack
GET/api/discord/callbackDiscord
GET/api/auth/callback/githubGitHub
GET/api/auth/callback/googleGoogle
POST/api/feishu/listener/initFeishu
POST/api/dingtalk/listener/initDingTalk
POST/api/qqbot/listener/initQQ Bot
POST/api/weixin/listener/initWeChat
POST/api/telegram/user-listener/initTelegram
POST/api/whatsapp/register-socketWhatsApp
POST/api/imessage/init-self-listeneriMessage

RAG Module (/api/rag/*)

MethodEndpointDescription
GET/api/rag/searchSearch documents
GET/api/rag/statsGet RAG statistics
GET/api/rag/documentsList documents
GET/api/rag/documents/[documentId]Get document
GET/api/rag/documents/[documentId]/binaryGet document binary
DELETE/api/rag/documents/[documentId]Delete document
POST/api/rag/uploadUpload document
POST/api/rag/upload/initInitialize upload
POST/api/rag/upload/chunkUpload chunk
POST/api/rag/upload/completeComplete upload
POST/api/rag/upload/asyncAsync upload
GET/api/rag/upload/async/statusCheck async upload status

Workspace Module (/api/workspace/*)

MethodEndpointDescription
GET/api/workspace/artifactsList artifacts
GET/api/workspace/filesBounded owner-scoped listing; follow nextCursor using cursor while hasMore is true (empty pages may continue); optional taskId/path, pageSize 1–1000. total is null, directory traversal order. Offset page is retired; expired cursors require a new scan.
GET/api/workspace/file/[...path]Get file by path
GET/api/workspace/previewPreview artifact
GET/api/workspace/external-previewExternal preview
GET/api/workspace/skillsList skills
GET/api/workspace/skills/[skillId]Get skill
POST/api/workspace/skillsCreate skill
PUT/api/workspace/skills/[skillId]Update skill
DELETE/api/workspace/skills/[skillId]Delete skill
POST/api/workspace/skills/toggleToggle skill
POST/api/workspace/skills/uploadUpload skill
GET/api/workspace/skills/metadataGet skill metadata

AI Module (/api/ai/*)

MethodEndpointDescription
POST/api/ai/chatChat completions (streaming)
GET/api/ai/chatCheck AI status
POST/api/ai/v1/chat/completionsV1 chat completions
POST/api/ai/v1/embeddingsGenerate embeddings
POST/api/ai/v1/images/generationsGenerate images
POST/api/ai/v1/audio/speechText-to-speech
POST/api/ai/v1/audio/transcriptionsSpeech-to-text
POST/api/ai/v1/messages/count_tokensCount tokens
POST/api/ai/v1/uploadUpload file for AI
GET/api/ai/v1/modelsList available models

Chat Example

curl -X POST https://app.openzhiyu.ai/api/ai/chat \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"}
    ],
    "stream": true
  }'

Insights Module (/api/insights/*, /api/chat-insights/*)

MethodEndpointDescription
GET/api/chat-insightsGet chat insights
GET/api/insights/brief-categoriesList brief categories
POST/api/insights/brief-categories/syncSync categories
POST/api/insights/brief-categories/overridesOverride categories
POST/api/insights/brief-categories/pinnedPin categories
POST/api/insights/brief-categories/cleanupCleanup categories
GET/api/insight-tabsList insight tabs
POST/api/insight-tabsCreate insight tab
PUT/api/insight-tabs/[tabId]Update tab
POST/api/insight-tabs/reorderReorder tabs

Billing Module (/api/billing/*)

MethodEndpointDescription
GET/api/billing/ledgerGet billing ledger

Error Handling

Error Response Format

// API errors return standard HTTP status codes
{
  error: string;      // Error message
  code?: string;       // Error code for programmatic handling
  cause?: string;      // Additional context
}

Common Status Codes

CodeMeaning
200Success
400Bad Request - Invalid input
401Unauthorized - Not authenticated
403Forbidden - Insufficient permissions
404Not Found
429Too Many Requests
500Internal Server Error

AI/Agent Usage

Local API Access

When running Zhiyu desktop app, the local API server runs on port 3414 (fallback: 3515):

EnvironmentBase URL
User Local Desktophttp://localhost:3414
User Local Desktop (fallback)http://localhost:3515

Authentication Token

The auth token is stored at ~/.openzhiyu/token (base64 encoded JWT). You must decode it before use:

# Decode base64 to get JWT token
TOKEN=$(cat ~/.openzhiyu/token | base64 -d)

# Verify token contents (decodes JWT payload)
echo "$TOKEN" | cut -d'.' -f2 | base64 -d 2>/dev/null | python3 -m json.tool

curl Examples

Important: All authenticated requests require the token to be base64 decoded first.

# Helper: Get decoded token
TOKEN=$(cat ~/.openzhiyu/token | base64 -d)

# 1. Check AI API status (no auth required)
curl http://localhost:3414/api/ai/chat

# 2. Get current user info
TOKEN=$(cat ~/.openzhiyu/token | base64 -d)
curl http://localhost:3414/api/remote-auth/user \
  -H "Authorization: Bearer $TOKEN"

# 3. Get subscription info
TOKEN=$(cat ~/.openzhiyu/token | base64 -d)
curl http://localhost:3414/api/remote-auth/subscription \
  -H "Authorization: Bearer $TOKEN"

# 4. Chat with AI (streaming)
TOKEN=$(cat ~/.openzhiyu/token | base64 -d)
curl -X POST http://localhost:3414/api/ai/chat \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"messages":[{"role":"user","content":"Hello!"}],"stream":true}'

# 5. Get chat insights (requires chatId)
TOKEN=$(cat ~/.openzhiyu/token | base64 -d)
curl "http://localhost:3414/api/chat-insights?chatId=xxx" \
  -H "Authorization: Bearer $TOKEN"

# 6. Search RAG documents
TOKEN=$(cat ~/.openzhiyu/token | base64 -d)
curl -X POST http://localhost:3414/api/rag/search \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query":"search term","limit":5}'

# 7. List workspace skills
TOKEN=$(cat ~/.openzhiyu/token | base64 -d)
curl http://localhost:3414/api/workspace/skills \
  -H "Authorization: Bearer $TOKEN"

# 8. Submit feedback
TOKEN=$(cat ~/.openzhiyu/token | base64 -d)
curl -X POST http://localhost:3414/api/remote-feedback \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content":"Feedback message","email":"user@example.com"}'

Production API Access

# Using production API
export TOKEN="your_production_token"
curl https://app.openzhiyu.ai/api/remote-auth/user \
  -H "Authorization: Bearer $TOKEN"

Summary

  • 129+ API endpoints across 20+ functional modules
  • Dual authentication: Session cookies (web) and Bearer tokens (Tauri)
  • RESTful JSON APIs with Zod validation
  • CloudApiClient for desktop/Tauri integration
  • SWR utilities for client-side data fetching
  • OAuth support for Google, GitHub, Slack, Discord, X
  • RAG for document retrieval and search
  • AI endpoints for chat, embeddings, images, audio

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.