Metadata-Version: 2.4
Name: copaw-openai-compat
Version: 0.1.0
Summary: OpenAI compatible provider templates for CoPaw - dynamic injection without modifying core code
Author: CoPaw Community
License: MIT
Project-URL: Homepage, https://github.com/anomalyco/copaw
Project-URL: Documentation, https://opencode.ai
Project-URL: Repository, https://github.com/anomalyco/copaw
Keywords: copaw,openai,llm,provider,ai
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.27.0
Requires-Dist: click>=8.0.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: rich>=13.0.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"

# copaw-openai-compat

OpenAI compatible provider templates for CoPaw.

This package allows dynamic injection of OpenAI-compatible providers into a running CoPaw instance without modifying the core code.

## Features

- **Zero Code Modification**: Inject providers via HTTP API
- **Multiple Templates**: Pre-configured templates for popular services
- **Custom Providers**: Create your own providers with custom endpoints
- **Web Console Integration**: Configured providers appear in CoPaw's Web UI

## Installation

```bash
pip install copaw-openai-compat
```

Or install from source:

```bash
cd copaw-openai-compat
pip install -e .
```

## Quick Start

### 1. Make sure CoPaw is running

```bash
copaw serve
```

### 2. List available templates

```bash
copaw-provider list
```

### 3. Install a provider

```bash
# Install Groq
copaw-provider install groq

# Install with API key
copaw-provider install groq --api-key gsk_xxx

# Install all templates
copaw-provider install --all
```

### 4. Configure in Web Console

Open http://localhost:8000 in your browser, navigate to Settings > Models, and configure the newly installed provider.

## Available Templates

| Template ID | Name | Base URL | Description |
|-------------|------|----------|-------------|
| `openai-compatible` | OpenAI Compatible | (user input) | Generic template for any OpenAI-compatible API |
| `groq` | Groq | `api.groq.com` | Ultra-fast inference platform |
| `together` | Together AI | `api.together.xyz` | Open-source model cloud |
| `openrouter` | OpenRouter | `openrouter.ai` | Unified API for 200+ LLMs |
| `moonshot` | Moonshot AI | `api.moonshot.cn` | Kimi intelligent assistant |
| `zhipu` | Zhipu AI | `open.bigmodel.cn` | GLM series models |
| `deepseek-api` | DeepSeek API | `api.deepseek.com` | Advanced reasoning model |
| `siliconflow` | SiliconFlow | `api.siliconflow.cn` | Cost-effective inference platform |

## CLI Commands

### `copaw-provider list`

List all available provider templates.

```bash
copaw-provider list
```

### `copaw-provider install <template_id>`

Install a provider template.

```bash
# Basic installation
copaw-provider install groq

# With API key
copaw-provider install groq --api-key gsk_xxx

# Override base URL
copaw-provider install openai-compatible --base-url https://api.custom.com/v1

# Install all templates
copaw-provider install --all
```

### `copaw-provider create <id>`

Create a custom provider (not from template).

```bash
copaw-provider create my-provider \
  --name "My Provider" \
  --base-url "https://api.example.com/v1" \
  --api-key "sk-xxx" \
  --api-key-prefix "sk-"
```

### `copaw-provider uninstall <provider_id>`

Uninstall a provider.

```bash
copaw-provider uninstall groq
copaw-provider uninstall my-provider -y  # Skip confirmation
```

### `copaw-provider installed`

List installed custom providers.

```bash
copaw-provider installed
```

### `copaw-provider check`

Check connection to CoPaw server.

```bash
copaw-provider check
```

## Environment Variables

| Variable | Description | Default |
|----------|-------------|---------|
| `COPAW_BASE_URL` | CoPaw server URL | `http://127.0.0.1:8000` |

## Adding Custom Templates

Templates are YAML files in the `templates/` directory:

```yaml
# templates/my-provider.yaml
id: my-provider
name: My Provider
description: Custom provider description
default_base_url: https://api.example.com/v1
api_key_prefix: sk-
chat_model: OpenAIChatModel
support_model_discovery: true
require_api_key: true
freeze_url: true
default_models:
  - id: model-1
    name: Model 1
  - id: model-2
    name: Model 2
```

## How It Works

1. **HTTP API**: Uses CoPaw's existing `/api/models/custom-providers` endpoint
2. **Dynamic Injection**: No modification to CoPaw's source code
3. **Persistent Storage**: Providers are saved in `~/.copaw.secret/providers/custom/`
4. **Web UI Integration**: Installed providers appear automatically in the Web Console

## License

MIT

## Disclaimer

This is an independent, community-developed plugin for CoPaw.
It is not affiliated with, endorsed by, or sponsored by the CoPaw project.
