> ## Documentation Index
> Fetch the complete documentation index at: https://portkey-docs-add-third-party-integration-issues-fixes.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Agentic Usage

> Add Portkey SDK skills to your AI coding assistant

Give your AI coding assistant the knowledge to work with Portkey SDKs by installing our official skills. This enables AI agents to understand Portkey's APIs, patterns, and best practices when helping you write code.

## Quick Start

Run this command in your project directory:

```bash theme={null}
npx add-skill portkey-ai/skills
```

This installs Portkey SDK skills, which teach your AI assistant how to use the SDKs effectively.

### Install a Specific Skill

<Tabs>
  <Tab title="Python SDK">
    ```bash theme={null}
    npx add-skill portkey-ai/skills --skill portkey-python-sdk
    ```
  </Tab>

  <Tab title="TypeScript SDK">
    ```bash theme={null}
    npx add-skill portkey-ai/skills --skill portkey-typescript-sdk
    ```
  </Tab>
</Tabs>

## Supported AI Coding Assistants

The skills work with any AI coding assistant that supports the Agent Skills format:

| Assistant                                                     | Status    |
| ------------------------------------------------------------- | --------- |
| [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | Supported |
| [Cursor](https://cursor.com)                                  | Supported |
| [OpenCode](https://opencode.ai)                               | Supported |
| [GitHub Copilot](https://github.com/features/copilot)         | Supported |
| [Codex](https://openai.com/index/openai-codex)                | Supported |
| [Amp](https://amp.dev)                                        | Supported |
| [Roo Code](https://roo.dev)                                   | Supported |

## What the Skills Provide

Once installed, your AI coding assistant will have knowledge of:

* **SDK Installation & Setup** — How to install and configure Portkey SDKs in Python and TypeScript projects
* **Chat Completions** — Making LLM calls with full streaming support
* **Observability & Tracing** — Adding trace IDs, metadata, and custom tags for debugging
* **Caching** — Semantic and simple caching to reduce costs and latency
* **Fallbacks** — Automatic failover when a provider fails
* **Load Balancing** — Distribute traffic across multiple providers or API keys
* **Multi-Provider Routing** — Route requests to 250+ LLMs through a unified API
* **Error Handling** — Proper retry logic and error handling patterns
* **Framework Integrations** — Working with LangChain, LlamaIndex, Strands, and Google ADK

## Example Usage

After installing the skills, your AI assistant can help you with tasks like:

**"Help me set up Portkey with OpenAI fallback to Anthropic"**

The assistant will know to use:

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    from portkey_ai import Portkey

    client = Portkey(
        api_key="YOUR_PORTKEY_API_KEY",
        config={
            "strategy": {"mode": "fallback"},
            "targets": [
                {
                    "override_params": {"model": "@openai/gpt-4o"}
                },
                {
                    "override_params": {"model": "@anthropic/claude-sonnet-4-20250514"}
                }
            ]
        }
    )

    response = client.chat.completions.create(
        messages=[{"role": "user", "content": "Hello!"}]
    )
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    import Portkey from 'portkey-ai';

    const client = new Portkey({
      apiKey: 'YOUR_PORTKEY_API_KEY',
      config: {
        strategy: { mode: 'fallback' },
        targets: [
          {
            overrideParams: { model: '@openai/gpt-4o' }
          },
          {
            overrideParams: { model: '@anthropic/claude-sonnet-4-20250514' }
          }
        ]
      }
    });

    const response = await client.chat.completions.create({
      messages: [{ role: 'user', content: 'Hello!' }]
    });
    ```
  </Tab>
</Tabs>

**"Add request tracing to my Portkey calls"**

The assistant understands the observability API:

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    response = client.with_options(
        trace_id="unique-trace-id",
        metadata={
            "user_id": "user-123",
            "session_id": "session-456",
            "environment": "production"
        }
    ).chat.completions.create(
        model="@openai/gpt-4o",
        messages=[{"role": "user", "content": "Summarize this document..."}]
    )
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    const response = await client.chat.completions.create({
      model: '@openai/gpt-4o',
      messages: [{ role: 'user', content: 'Summarize this document...' }]
    }, {
      traceId: 'unique-trace-id',
      metadata: {
        userId: 'user-123',
        sessionId: 'session-456',
        environment: 'production'
      }
    });
    ```
  </Tab>
</Tabs>

**"Enable semantic caching for my LLM requests"**

```python theme={null}
client = Portkey(
    api_key="YOUR_PORTKEY_API_KEY",
    config={
        "cache": {
            "mode": "semantic",  # or "simple" for exact match
            "max_age": 3600      # TTL in seconds
        }
    }
)

# Similar queries return cached responses
response = client.chat.completions.create(
    model="@openai/gpt-4o",
    messages=[{"role": "user", "content": "What is the capital of France?"}]
)
```

## Installation Options

### List Available Skills

```bash theme={null}
npx add-skill portkey-ai/skills --list
```

### Project-Level Installation (Default)

Installs skills to your current project directory:

```bash theme={null}
npx add-skill portkey-ai/skills
```

### Global Installation

Installs skills globally so they're available across all your projects:

```bash theme={null}
npx add-skill portkey-ai/skills --global
```

### Target Specific Agent

Install for a specific AI coding assistant only:

```bash theme={null}
npx add-skill portkey-ai/skills --agent cursor
npx add-skill portkey-ai/skills --agent claude
```

## Manual Installation

If you prefer to install manually, copy the skill files to your project's skills directory:

<Tabs>
  <Tab title="Claude Code">
    ```bash theme={null}
    mkdir -p .claude/skills/portkey-python-sdk
    curl -o .claude/skills/portkey-python-sdk/SKILL.md \
      https://raw.githubusercontent.com/portkey-ai/skills/main/skills/portkey-python-sdk/SKILL.md
    ```
  </Tab>

  <Tab title="Cursor">
    ```bash theme={null}
    mkdir -p .cursor/skills/portkey-python-sdk
    curl -o .cursor/skills/portkey-python-sdk/SKILL.md \
      https://raw.githubusercontent.com/portkey-ai/skills/main/skills/portkey-python-sdk/SKILL.md
    ```
  </Tab>
</Tabs>

## Updating the Skills

To get the latest SDK documentation, re-run the install command:

```bash theme={null}
npx add-skill portkey-ai/skills
```

The skills are automatically updated when new SDK versions are released.

## Repository

The skill source is available at: [github.com/portkey-ai/skills](https://github.com/portkey-ai/skills)

Contributions and feedback are welcome.

<CardGroup cols={2}>
  <Card title="Python SDK Docs" icon="python" href="/api-reference/sdk/python">
    Full Python SDK documentation
  </Card>

  <Card title="TypeScript SDK Docs" icon="js" href="/api-reference/sdk/node">
    Full TypeScript SDK documentation
  </Card>

  <Card title="Skills Repository" icon="github" href="https://github.com/portkey-ai/skills">
    View the skills source on GitHub
  </Card>

  <Card title="Discord Community" icon="discord" href="https://portkey.ai/discord">
    Get help from the community
  </Card>
</CardGroup>
