ai-service

ai-service is a skill for Claude Code, Codex from nongjun/feishu-cursor-claw. It costs 67 tokens per session (765 once invoked), scanned A, original, MIT.

A shared service for connecting applications to language and media AI models. It supports text conversations, streaming responses, image understanding, PDF, audio and video analysis, and image generation through configured providers.

In plain words
What is it for?
Use it to add chat, document or media analysis, image understanding, streamed answers, and generated images to an application.
Why use it?
It gives different modules one way to call AI and can switch to another configured provider when the preferred one fails.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to add chat, document or media analysis, image understanding, streamed answers, and generated images to an application.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/nongjun/feishu-cursor-claw/ai-service
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add nongjun/feishu-cursor-claw --skill ai-service
Clone the repo
git clone --depth 1 https://github.com/nongjun/feishu-cursor-claw

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ai-service

README.md
[![agentmods](https://agentmods.dev/badge/skills/nongjun/feishu-cursor-claw/ai-service/github.svg)](https://agentmods.dev/skills/nongjun/feishu-cursor-claw/ai-service)
Your own site
<a href="https://agentmods.dev/skills/nongjun/feishu-cursor-claw/ai-service"><img src="https://agentmods.dev/badge/skills/nongjun/feishu-cursor-claw/ai-service/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for ai-service

Your own site · 80×15
<a href="https://agentmods.dev/skills/nongjun/feishu-cursor-claw/ai-service"><img src="https://agentmods.dev/badge/skills/nongjun/feishu-cursor-claw/ai-service.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 67 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 765 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00067 $0.00765
Opus 5 $0.00034 $0.00382
Sonnet 5 $0.00013 $0.00153
Haiku 4.5 $0.00007 $0.00076

Measured 10d ago against content hash 8ebff8a22423, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

ai-service scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

参考代码/njcursor/skills/ai-service/SKILL.md · 65 lines

What it actually says

AI Service

架构概览

调用方 → AIService → 门户模型注册表 → 4sapi(首选)/ sodao(次选)/ OpenRouter(备选),按 function_code 匹配绑定模型。

核心能力

方法 用途
chat() 文本对话(支持智能降级)
chat_stream() 流式输出
chat_stream_thinking() Thinking 模型专用流式接口
vision() 图片理解
analyze_pdf() PDF 分析
analyze_audio() 音频分析
analyze_video() 视频分析
generate_image() 图像生成

SOP:接入 AI 功能

  1. 导入:from shared_backend.services.ai_service import AIService
  2. 实例化:AIService(module_code="模块名", db_session=db)
  3. 注册提示词(可选):用于日志追踪
  4. 调用对应方法,传入 prompt_name 用于统计

重点关注

三服务商 + 降级链

  • 首选 4sapi,次选 sodao(苏打API),备选 OpenRouter
  • 降级链(三阶段):
    • Phase 1(4sapi):Claude Opus 4.6 Thinking → Gemini 3.1 Pro → Gemini Flash
    • Phase 2(sodao):Gemini 3.1 Pro → Gemini Flash(不重试 opus
    • Phase 3(OpenRouter):DeepSeek Chat V3 → Qwen 2.5 72B(国产模型兜底)
  • 降级缓存机制:某模型连续失败后暂时跳过

门户模型注册表(v2)

  • 管理员在门户「AI 配置 → 模型管理」注册可用模型(ai_available_models 表),每个模型自带 base_url + api_key + model
  • 各模块在「AI 配置 → 模型绑定」通过 module_code + function_code 绑定指定模型(ai_module_model_config 表)
  • 运行时 AIService(module_code, function_code=, db_session=) 自动查询绑定,优先使用绑定模型,未绑定时走全局降级链
  • 门户后台可动态切换模型,无需改代码

JSON 解析工具

  • parse_ai_json_response(content) — 从 AI 回复中提取 JSON
  • safe_parse_ai_json(content, default) — 带默认值的安全解析
  • 自动处理 <thinking> 标签、Markdown 代码块、混合文本

API Key 管理

  • 统一从门户系统动态获取(SAPI_API_KEY / SODAO_API_KEY / OPENROUTER_API_KEY),禁止硬编码
  • 门户地址配置:PORTAL_API_URL

参考文件

  • 公共模块/shared_backend/services/ai_service.py(主实现)
  • 文档/核心信念/AI调用规范.md
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 65 lines · 67 tokens per session scan A 8ebff8a22423

Subscribe to this mod's changes

ai-service is a skill published in the GitHub repository nongjun/feishu-cursor-claw (14 stars, last pushed 1mo ago), licensed MIT. It adds 67 tokens to every session and 765 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

firebase-ai

Use when setting up firebaseai, generating text/chat with Gemini, streaming AI output, building multimodal prompts, or handling AI errors.

evanca/flutter-ai-rules · 30 tokens

audit-langfuse-llm

Run a PDCA quality audit on LLM/AI features: traces, prompts, costs, evals, grounding, hallucination. Use for "audit LLM quality", "check Langfuse", "audit prompts", "check AI quality", "audit AI costs", "check traces". Jailbreak/OWASP LLM → audit-llm-security. Token caps → plan-llm-cost-guardrails.

kensaurus/cursor-kenji · 93 tokens

data-pipeline

Wire ETL, ingestion, cron, edge-function, and queue jobs correctly. Use for "build a pipeline", "sync X into Y", "nightly aggregation", "cron double-counts", "dedupe", "backfill", "the numbers are wrong after a retry". Bakes in idempotency, atomic writes, data contracts, dead-letter, and observability.

kensaurus/cursor-kenji · 81 tokens

plan-llm-cost-guardrails

Audit an LLM-powered app for runaway-cost and quota-abuse exposure, then produce a phased guardrail plan. Use when the user says "cap my AI costs", "my LLM bill could blow up", "rate limit my AI", "token budget", "runaway agent loop", or is hardening LLM features before launch.

kensaurus/cursor-kenji · 78 tokens

audit-llm-security

Read-only OWASP LLM Top 10 audit of app-facing AI: prompt injection, data leakage, unsafe output/agency, RAG risks, misinformation, and unbounded spend. Use when "audit LLM security", "prompt injection", "jailbreak my chatbot", or "is my AI safe?". General app security → audit-security.

kensaurus/cursor-kenji · 76 tokens

embedding-pipeline-builder

Builds document embedding pipelines with text chunking, embedding generation, indexing, and retrieval optimization. Use when users request "embedding pipeline", "document indexing", "text chunking", "RAG preprocessing", or "semantic indexing".

patricio0312rev/skills · 51 tokens