Sign inSign up

nghyane/copilot-api

By nghyane

•Updated over 1 year ago

Image
0

1.5K

nghyane/copilot-api repository overview

⁠GitHub Copilot API Docker Image

A wrapper around GitHub Copilot API to make it OpenAI compatible, making it usable for other tools.

⁠Quick Start

⁠1. Get GitHub Token

First, authenticate with GitHub Copilot:

npx copilot-api@latest auth
⁠2. Run Container
docker run -d \
  --name copilot-api \
  -p 4141:4141 \
  -e GH_TOKEN=your_github_token_here \
  nghyane/copilot-api:latest
⁠3. Test API
curl http://localhost:4141/v1/models

⁠Environment Variables

VariableDescriptionRequired
GH_TOKENGitHub token with Copilot access✅ Yes

⁠Docker Compose

version: '3.8'
services:
  copilot-api:
    image: nghyane/copilot-api:latest
    ports:
      - "4141:4141"
    environment:
      - GH_TOKEN=your_github_token_here
    restart: unless-stopped

⁠Usage Examples

⁠OpenAI Compatible
# List models
curl http://localhost:4141/v1/models

# Chat completion
curl -X POST http://localhost:4141/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

# Streaming
curl -X POST http://localhost:4141/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o", 
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": true
  }'
⁠With Tools/Functions
curl -X POST http://localhost:4141/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "What is the weather?"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get weather information",
        "parameters": {
          "type": "object",
          "properties": {
            "location": {"type": "string"}
          }
        }
      }
    }]
  }'

⁠Supported Architectures

  • linux/amd64 (Intel/AMD x64)
  • linux/arm64 (ARM64 - Apple Silicon, ARM servers)

⁠Available Tags

  • latest - Latest stable version
  • 0.3.1 - Specific version
  • 0.3.0, 0.2.x - Previous versions

⁠Health Check

curl http://localhost:4141/health

⁠Configuration Options

Run with additional options:

docker run -d \
  --name copilot-api \
  -p 4141:4141 \
  -e GH_TOKEN=your_token \
  nghyane/copilot-api:latest \
  start --port 4141 --verbose

⁠Troubleshooting

⁠Container won't start
  • Check if GitHub token is valid
  • Ensure port 4141 is not in use
  • Check container logs: docker logs copilot-api
⁠API returns 401
  • Verify GitHub token has Copilot access
  • Re-authenticate: npx copilot-api@latest auth
⁠Rate limiting
  • Use --rate-limit option to set custom limits
  • Add --rate-limit-wait to queue requests

⁠License

MIT License - see repository for details.

Tag summary

Content type

Image

Digest

sha256:beb8820dc…

Size

57.1 MB

Last updated

over 1 year ago

docker pull nghyane/copilot-api