Refly Documentation
repository·main·Indexed 25 days ago
https://github.com/refly-ai/reflyRefly is an open-source agent skills builder that transforms business logic (SOPs) into stable, versioned, and executable agent skills. It provides a deterministic runtime and a central skill registry to bridge the gap between raw APIs and intelligent agents. The system includes a VectorSearchService supporting Qdrant and LanceDB backends, a comprehensive VectorFilter union type for complex metadata filtering, and a local observability Trace Stack for distributed tracing, metrics, and log aggregation.
What's inside Refly
- Refly Skills is an official executable skill registry containing versioned, reusable agent capabilities. Unlike one-off prompts, these are durable infrastructure that can be executed instantly, exported to platforms like Claude Code, or deployed as APIs. You can explore the registry in the official GitHub repository.
Integrate tools and protocols with Refly
mainRefly acts as a bridge between your existing enterprise toolchain and agent runtimes. You can ingest data and logic using several methods:
- Native Tools: Seamless integration with over 3,000 industrial-grade APIs including Stripe, Slack, Salesforce, and GitHub. A full list of supported providers is available in
config/provider-catalog.json. - MCP Support: Native compatibility with any Model Context Protocol (MCP) server to extend agent capabilities beyond standard APIs.
- Private Skills Connectors: Securely connect to enterprise databases, custom scripts, and internal systems.
- Native Tools: Seamless integration with over 3,000 industrial-grade APIs including Stripe, Slack, Salesforce, and GitHub. A full list of supported providers is available in
Understand the Credit-Based Usage System
mainIn the Cloud version of Refly (v0.9.0+), model usage is managed via a unified credit system instead of manual API key configuration:
- All model types (text, image, audio, and video) consume credits.
- Manual API key setup is no longer required for standard usage.
- Early unlimited members retain free access to major models including Kimi, GPT-4.1, and Gemini Pro.
Understand Auto Model Smart Routing
mainAuto Model is a virtual model layer that decouples the user's selection from the actual LLM execution. When a user selects "Auto", the system silently routes the request to the best available model based on rules, scene, toolset, and user context.
Key Characteristics
- UI Stability: The user always sees "Auto" in the UI, even if the backend model changes.
- Cost Optimization: Refly can optimize costs without user reconfiguration.
- Billing: When using Auto routing, billing is calculated using the Auto model's specific credit rates (80 credits/1M input tokens, 400 credits/1M output tokens), regardless of which real model is used for execution.
- Identification: The utility
isAutoModel()(frompackages/utils/src/auto-model.ts) identifies this mode by checking ifconfig.modelId === 'auto'.
Export Refly Skills to agent runtimes and platforms
mainOnce Skills are defined, they can be exported to various environments:
- AI Coding Tools: Export natively to Claude Code and Cursor, allowing agents to use your versioned Skills as standardized tools.
- App Builders: Provide logic support for Lovable or custom frontend applications via stateful, authenticated APIs.
- Automation Hubs: Deploy as intelligent webhooks triggered by platforms like Slack or Microsoft Teams to execute complex SOPs.
- Agent Frameworks: Direct compatibility with AutoGen, Manus, and custom LangChain/Python stacks.
Understand Programmatic Tool Calling (PTC) Architecture
mainPTC (Programmatic Tool Calling) is a design pattern in Refly that replaces standard JSON-schema tool calling with Python code execution in a sandbox. Instead of the model calling tools via function-calling, the model writes Python code that imports a generated SDK and calls tools as class methods.
Key Advantages:
- Enables complex multi-step orchestration in a single model turn.
- Supports batch processing, conditional logic, loops, and in-flight data transformation.
- Provides programmatic control like error handling and retries.
Execution Flow:
- The Agent decides to use PTC by writing
execute_codewith Python. - The Sandbox receives the code, an injected SDK, and environment variables.
- The Python code executes:
result = ToolsetClass.method_name(param=value). - The SDK makes an HTTP POST request to
/v1/tool/executeon the Refly API. - The Refly API executes the tool and returns the result to the Python sandbox.
- Results are polled and streamed to the frontend via SSE.
Access the Refly API
mainThe Refly API provides RESTful endpoints to programmatically run workflows, upload files, and query execution status. The base URL for all API requests ishttps://api.refly.ai/v1.Stop Refly services
mainTo stop the running services, use the following commands:
Stop API server:
kill $(cat /tmp/refly-api.pid)Stop Docker containers:
docker-compose -f deploy/docker/docker-compose.dev.yml downBuild and preview Refly.AI documentation
mainUse the following commands to build the documentation site for production or to preview a build locally:
- Build the site:
pnpm build - Preview the build:
pnpm preview
pnpm build pnpm preview- Build the site:
Install the @refly/cli
mainInstall the Refly CLI globally using npm to manage and execute Refly workflows via the command line.
```bash npm install -g @refly/cli ```埋Enable type-aware linting in ESLint
mainFor production applications, it is recommended to enable type-aware lint rules in your ESLint configuration.
- Update the
parserOptionsin your ESLint config file to includeprojectandtsconfigRootDir. - Update your
extendslist to use type-checked TypeScript rules instead of standard recommended rules. - Add React-specific linting plugins for better coverage.
export default { // other rules... parserOptions: { ecmaVersion: 'latest', sourceType: 'module', project: ['./tsconfig.json', './tsconfig.node.json'], tsconfigRootDir: __dirname, }, }- Update the
View model thinking processes (Chain of Thought)
mainFor models that support reasoning (such asClaude 3.7 Sonnet ThinkingandDeepSeek R1), Refly supports streaming the display of the model's thinking chains. Users can expand or collapse these thinking chains in the UI.