> ## Documentation Index
> Fetch the complete documentation index at: https://docs.profy.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrate with Claude Code / Codex / Cursor

> Connect Profy Experts to AI coding tools (Claude Code, Codex, Cursor, Cline, Gemini CLI) so developers can invoke your Expert directly from their IDE.

Profy Experts can be consumed as a **Skill** or **MCP Server** by mainstream AI coding tools, giving developers access to Expert capabilities without leaving their IDE.

## Supported Tools

| Tool           | Integration Method | Status      |
| -------------- | ------------------ | ----------- |
| Claude Code    | Skill / MCP Server | ✅ Available |
| Cursor         | Skill              | ✅ Available |
| Codex (OpenAI) | Skill              | ✅ Available |
| Cline          | Skill              | ✅ Available |
| Gemini CLI     | Skill              | ✅ Available |

## Prerequisites

* Profy account with Developer role
* API Key (create at [Developer Console](https://app.profy.cn/developer), format `profy_sk_*`)
* Expert must have API access enabled (`apiAccess: "open"`)

***

## Method 1: Skill Integration (Recommended, Zero Infrastructure)

A Skill is a Markdown file that teaches AI coding tools how to call the Profy API. Once installed, the agent automatically knows when and how to invoke Profy Experts.

### Claude Code

```bash theme={null}
# Download Skill to your project
curl -o .claude/skills/profy-api.md \
  https://raw.githubusercontent.com/AresEkb/profy/main/knowledge/skills/profy-developer-api/SKILL.md

# Or copy manually
mkdir -p .claude/skills && cp profy-developer-api/SKILL.md .claude/skills/profy-api.md
```

Set your API Key:

```bash theme={null}
export PROFY_API_KEY="profy_sk_your_key_here"
```

Then simply tell Claude Code:

> "Use Profy's react-architect Expert to review this code"

Claude Code will follow the Skill instructions and call `POST https://api.profy.cn/v1/experts/react-architect/chat` automatically.

### Cursor

```bash theme={null}
mkdir -p .cursor/skills/profy-api
cp SKILL.md .cursor/skills/profy-api/SKILL.md
```

### Codex / Cline / Gemini CLI

Place `SKILL.md` in your project's agent skills directory (exact path varies by tool). Ensure the `PROFY_API_KEY` environment variable is set.

***

## Method 2: MCP Server Integration

MCP (Model Context Protocol) provides deeper integration, allowing AI tools to invoke Profy Experts via **structured tool calls**.

### Configure `.mcp.json`

Create `.mcp.json` at your project root:

```json theme={null}
{
  "mcpServers": {
    "profy": {
      "type": "http",
      "url": "https://mcp.profy.cn/mcp",
      "headers": {
        "Authorization": "Bearer ${PROFY_API_KEY}"
      }
    }
  }
}
```

### Register in Claude Code

```bash theme={null}
claude mcp add --transport http profy https://mcp.profy.cn/mcp
```

### Available Tools (after MCP Server launch)

| Tool                | Description                               |
| ------------------- | ----------------------------------------- |
| `search_experts`    | Search Expert marketplace                 |
| `get_expert_detail` | Get Expert details                        |
| `invoke_expert`     | Invoke Expert (returns structured result) |
| `chat_completion`   | OpenAI-compatible Chat                    |

<Note>
  The MCP Server endpoint `mcp.profy.cn` is under development. Please use the Skill method for now.
</Note>

***

## API Endpoint Reference

All requests require `Authorization: Bearer $PROFY_API_KEY`.

Base URL: `https://api.profy.cn`

| Method | Path                            | Description                            |
| ------ | ------------------------------- | -------------------------------------- |
| POST   | `/v1/experts`                   | Search Experts (keyword/category/page) |
| GET    | `/v1/experts/{identifier}`      | Expert details                         |
| POST   | `/v1/experts/{identifier}/chat` | Invoke Expert (SSE streaming)          |
| POST   | `/v1/chat/completions`          | OpenAI-compatible Chat Completions     |
| GET    | `/v1/experts/categories`        | Expert category list                   |

### Invoke an Expert

```bash theme={null}
curl -N https://api.profy.cn/v1/experts/react-architect/chat \
  -H "Authorization: Bearer $PROFY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Review this code for performance issues:\n\nfunction App() { ... }"
  }'
```

**Response**: SSE stream (`text/event-stream`). The `X-Session-Id` header is used for multi-turn conversations.

### Multi-turn Conversations

```bash theme={null}
curl -N https://api.profy.cn/v1/experts/react-architect/chat \
  -H "Authorization: Bearer $PROFY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "How about using virtualization?",
    "session_id": "SESSION_ID_FROM_FIRST_CALL"
  }'
```

### OpenAI-Compatible Chat

```bash theme={null}
curl -s https://api.profy.cn/v1/chat/completions \
  -H "Authorization: Bearer $PROFY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-chat",
    "messages": [{"role": "user", "content": "Hello"}],
    "stream": true
  }'
```

***

## For Creators: Enable API Access for Your Expert

1. Edit your Expert in Studio
2. Set **API Access** to `Open` (any developer with an API Key can invoke)
3. Publish a new version

```bash theme={null}
# Or via API
curl -X PUT https://api.profy.cn/v1/creator/experts/{identifier} \
  -H "Authorization: Bearer $PROFY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"apiAccess": "open"}'
```

Once enabled, your Expert can be invoked by developers worldwide from Claude Code, Cursor, and Codex.

***

## FAQ

<AccordionGroup>
  <Accordion title="What's the difference between Skill and MCP?">
    * **Skill**: Plain text instructions that teach AI how to curl your API. Zero infrastructure, cross-platform compatible.
    * **MCP Server**: Structured tool protocol where AI makes function calls. More powerful but requires server-side support.

    Start with Skills. Upgrade to MCP Server seamlessly once available.
  </Accordion>

  <Accordion title="Getting 403 Forbidden?">
    The Expert's `api_access` field is `off` (default). Ask the Expert creator to enable API access, or try a different Expert with `api_access: open`.
  </Accordion>

  <Accordion title="How to parse SSE streams?">
    Responses use standard Server-Sent Events format. Each line starts with `data: ` and the stream ends with `data: [DONE]`. Most HTTP clients and AI tools natively support SSE parsing.
  </Accordion>

  <Accordion title="Which models are supported?">
    Via the `/v1/chat/completions` endpoint, all platform-configured models are available (DeepSeek, Qwen, etc.). Available models depend on platform configuration.
  </Accordion>

  <Accordion title="How does billing work?">
    Token-based billing (METERED). Credits are deducted from the API Key owner's account. View usage in the Developer Console.
  </Accordion>
</AccordionGroup>

***

## Next Steps

* [API Reference](/api/post-invoke) — Detailed parameter documentation for all endpoints
* [SDK Quickstart](/sdk/quickstart) — TypeScript/Python SDK integration
* [Creator Incentives](/documentation/creator-incentive) — Revenue sharing from API invocations
