Skip to main content

OpenAI compatible provider templates for CoPaw - dynamic injection without modifying core code

Project description

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
  • Auto-detection: Automatically reads CoPaw's port from ~/.copaw/config.json

Installation

pip install copaw-openai-compat

Or install from source:

cd copaw-openai-compat
pip install -e .

Quick Start

1. Make sure CoPaw is running

# Start CoPaw API server
copaw app

# Or start as daemon
copaw daemon start

2. List available templates

copaw-provider list

3. Install a provider

# 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:8088 in your browser, navigate to Settings > Models, and configure the newly installed provider.

Port Configuration

The plugin automatically reads CoPaw's port from ~/.copaw/config.json. If you're using a different port:

# Specify custom port
copaw-provider --base-url http://127.0.0.1:YOUR_PORT install groq

# Or set environment variable
export COPAW_BASE_URL=http://127.0.0.1:YOUR_PORT
copaw-provider install groq

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.

copaw-provider list

copaw-provider install <template_id>

Install a provider template.

# 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).

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.

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

copaw-provider installed

List installed custom providers.

copaw-provider installed

copaw-provider check

Check connection to CoPaw server and show current configuration.

copaw-provider check

copaw-provider config

Show current configuration details.

copaw-provider config

Environment Variables

Variable Description Default
COPAW_BASE_URL CoPaw server URL Auto-detected from ~/.copaw/config.json

Adding Custom Templates

Templates are YAML files in the templates/ directory:

# 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

Troubleshooting

"Cannot connect to CoPaw"

Make sure CoPaw is running:

copaw app
# or
copaw daemon start

Wrong port

Check your CoPaw port:

copaw-provider config

Or specify manually:

copaw-provider --base-url http://127.0.0.1:YOUR_PORT install groq

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

copaw_openai_compat-0.1.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

copaw_openai_compat-0.1.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file copaw_openai_compat-0.1.1.tar.gz.

File metadata

  • Download URL: copaw_openai_compat-0.1.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for copaw_openai_compat-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a9ad8ecea3d7b71ba0f0f003c4fd875a9b41ed0223699c2baafee38abdecea15
MD5 d20fc43afc4879ff8a2bf3a1fe5886e0
BLAKE2b-256 412414b57f3ca3c9e0ed478b534a47adfadff6eb267d203d8d367ff2ef8e892a

See more details on using hashes here.

File details

Details for the file copaw_openai_compat-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for copaw_openai_compat-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 84a2cece5cbf168ceef378e47dd92f2a37968ea8157d4d73cc1061ff7fa915f5
MD5 6f4b04cc5606cbb1483b1b03fe9fea1d
BLAKE2b-256 8380000b9858bcb4b09db42f1b1872179180bd98626754f9faa9b02006449f61

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page