{"id":51371825,"url":"https://github.com/mark0725/go-agents-proxy","last_synced_at":"2026-07-03T07:33:47.507Z","repository":{"id":331792535,"uuid":"1130982881","full_name":"mark0725/go-agents-proxy","owner":"mark0725","description":"An Agents API proxy server written in Go. Accepts Anthropic/OpenAI/Google-format requests.","archived":false,"fork":false,"pushed_at":"2026-06-03T14:14:34.000Z","size":411,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-03T16:09:18.018Z","etag":null,"topics":["agent","claude-code","codex"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mark0725.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-09T09:51:10.000Z","updated_at":"2026-06-03T14:24:56.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mark0725/go-agents-proxy","commit_stats":null,"previous_names":["mark0725/go-claude-code-proxy","mark0725/go-agents-proxy"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/mark0725/go-agents-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mark0725%2Fgo-agents-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mark0725%2Fgo-agents-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mark0725%2Fgo-agents-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mark0725%2Fgo-agents-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mark0725","download_url":"https://codeload.github.com/mark0725/go-agents-proxy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mark0725%2Fgo-agents-proxy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35077507,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","claude-code","codex"],"created_at":"2026-07-03T07:33:46.248Z","updated_at":"2026-07-03T07:33:47.499Z","avatar_url":"https://github.com/mark0725.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Agents Proxy\n\nAgents Proxy is a configurable LLM API proxy service. It provides a single entry point for clients and forwards requests to configured upstream providers such as Anthropic, OpenAI, Google/Gemini, or compatible third-party APIs.\n\nThe service is designed for managing multiple routes, models, providers, API endpoints, credentials, fallback targets, logs, and request testing from one place.\n\n## Features\n\n- **Unified LLM endpoint**: Send requests through `/llm/\u003croute-id\u003e/v1/messages`.\n- **Multi-provider support**: Use Anthropic, OpenAI, Google/Gemini, or compatible API providers.\n- **Model mapping**: Map client model names to provider-specific upstream model IDs.\n- **Provider failover**: Configure multiple ordered targets for a route and automatically try the next target when one fails.\n- **API type selection**: Configure `api_type` at the route and model-mapping level.\n- **Streaming responses**: Supports SSE streaming responses.\n- **Tool calling**: Supports tool-use requests and responses.\n- **Web management UI**: Manage routes, providers, users, tokens, logs, app settings, and request tests from the built-in UI.\n- **Hot reload**: Configuration changes can be loaded without restarting the service.\n- **Authentication**: Supports API key authentication with `x-api-key` and `Authorization: Bearer` headers.\n- **Logging**: Provides application logs and per-request LLM call logs.\n- **HTTP proxy support**: Supports global proxy settings and provider-level proxy settings.\n\n## Quick Start\n\n### 1. Create `config.yaml`\n\nCreate a `config.yaml` file with at least one credential, one route, and one provider.\n\n```yaml\napp:\n  level: info\n  auth: true\n  listen: \"0.0.0.0\"\n  port: \"8082\"\n\nusers:\n  - name: admin\n    token: your_token\n\ntokens:\n  - id: claude-code\n    token: your_token\n\nroutes:\n  claude-code:\n    api_type: anthropic\n    targets:\n      - name: primary\n        enable: true\n        models:\n          - match_model: \"*\"\n            provider: anthropic\n            model_id: claude-sonnet-4-20250514\n            api_name: default\n            api_type: anthropic\n\nproviders:\n  anthropic:\n    enable: true\n    models:\n      - model_id: claude-sonnet-4-20250514\n    apis:\n      - name: default\n        api_type: anthropic\n        base_url: https://api.anthropic.com/v1\n        api_key: your_api_key\n```\n\nIf a model mapping does not define `api_type`, it uses the route's `api_type` by default.\n\n### 2. Start the service\n\n```bash\ngo run main.go\n```\n\nUse a custom config path:\n\n```bash\ngo run main.go /path/to/config.yaml\n```\n\n### 3. Send a request\n\n```bash\ncurl -X POST http://localhost:8082/llm/claude-code/v1/messages \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-api-key: your_token\" \\\n  -d '{\n    \"model\": \"claude-sonnet-4-20250514\",\n    \"max_tokens\": 1024,\n    \"messages\": [\n      {\"role\": \"user\", \"content\": \"Hello\"}\n    ]\n  }'\n```\n\n### 4. Open the web UI\n\nOpen the management dashboard in a browser:\n\n```text\nhttp://localhost:8082/\n```\n\nAfter logging in, you can manage routes, providers, users, tokens, app settings, logs, and test requests.\n\n![admin ui](./docs/ui-1.png)\n\n## LLM API\n\n| Route | Description |\n|-------|-------------|\n| `/llm/\u003croute-id\u003e/v1/messages` | Send an LLM request to the configured route |\n| `/llm/\u003croute-id\u003e/v1/messages/count_tokens` | Count tokens for a request |\n\n## Management API\n\n| Route | Method | Description |\n|-------|--------|-------------|\n| `/api/config` | GET | Get the current configuration |\n| `/api/config` | POST | Update the configuration |\n| `/api/routes` | GET | List routes |\n| `/api/providers` | GET | List providers |\n| `/api/logs/llm` | GET | Query LLM call logs |\n| `/api/logs/app` | GET | Query application logs |\n\n## Configuration Reference\n\n### `app`\n\n| Field | Description |\n|-------|-------------|\n| `level` | Application log level: `debug`, `info`, `warn`, or `error` |\n| `auth` | Enables or disables authentication |\n| `listen` | Listen address |\n| `port` | Listen port |\n\n### `users` and `tokens`\n\nUse `users` and `tokens` to configure credentials for clients that access Agents Proxy.\n\nSupported request headers:\n\n```text\nx-api-key: your_token\nAuthorization: Bearer your_token\n```\n\nIf `app.auth` is `false`, requests do not require authentication.\n\n### `routes`\n\nRoutes define client-facing API entries and model forwarding rules.\n\n| Field | Description |\n|-------|-------------|\n| `api_type` | Client-facing API type: `anthropic`, `openai`, or `gemini` |\n| `targets` | Ordered target groups used for forwarding and failover |\n| `targets[].name` | Target group name |\n| `targets[].enable` | Enables or disables the target group |\n| `targets[].models[].match_model` | Client model matching rule; supports exact match, prefix wildcard, and `*` |\n| `targets[].models[].provider` | Provider used for the matched model |\n| `targets[].models[].model_id` | Upstream model ID sent to the provider |\n| `targets[].models[].api_name` | Provider API endpoint name |\n| `targets[].models[].api_type` | Provider API type; defaults to the route `api_type` when omitted |\n\n### `providers`\n\nProviders define upstream services, models, API endpoints, and optional proxy settings.\n\n| Field | Description |\n|-------|-------------|\n| `enable` | Enables or disables the provider |\n| `proxy` | Optional provider-specific HTTP proxy URL |\n| `models` | Models available for this provider |\n| `apis[].name` | API endpoint name |\n| `apis[].api_type` | API endpoint type: `anthropic`, `openai`, or `gemini` |\n| `apis[].base_url` | API endpoint base URL |\n| `apis[].api_key` | API key for the endpoint |\n\nWithin the same provider, the combination of `api_name` and `api_type` must be unique.\n\n## Environment Variables\n\n| Variable | Required | Default | Description |\n|----------|----------|---------|-------------|\n| `PORT` | No | `8082` | Service port; can be overridden by `app.port` in `config.yaml` |\n| `LOG_LEVEL` | No | `info` | Log level; can be overridden by `app.level` in `config.yaml` |\n| `PROXY_URL` | No | - | Global HTTP proxy URL |\n\nA `.env` file can be used for these environment variables. API keys and upstream base URLs should be configured in `config.yaml`.\n\n## Build\n\n```bash\ngo build -o agents-proxy .\n```\n\nRun the built binary:\n\n```bash\n./agents-proxy\n```\n\nRun with a custom config path:\n\n```bash\n./agents-proxy /path/to/config.yaml\n```\n\n## Docker Deployment\n\nBuild an image:\n\n```bash\ndocker build -t agents-proxy .\n```\n\nRun a container:\n\n```bash\ndocker run -d \\\n  -p 8082:8082 \\\n  -v /etc/localtime:/etc/localtime:ro \\\n  -v /etc/timezone:/etc/timezone:ro \\\n  -e \"TZ=Asia/Shanghai\" \\\n  -v $(pwd)/config.yaml:/app/config.yaml \\\n  -v $(pwd)/logs:/app/logs \\\n  --name agents-proxy \\\n  agents-proxy\n```\n\nOr use the published image:\n\n```bash\ndocker run -d \\\n  -p 8082:8082 \\\n  -v /etc/localtime:/etc/localtime:ro \\\n  -v /etc/timezone:/etc/timezone:ro \\\n  -e \"TZ=Asia/Shanghai\" \\\n  -v $(pwd)/config.yaml:/app/config.yaml \\\n  -v $(pwd)/logs:/app/logs \\\n  --name agents-proxy \\\n  ghcr.io/mark0725/go-agents-proxy:latest\n```\n\nMake sure the host config file and log directory exist before starting the container:\n\n```text\n$(pwd)/config.yaml\n$(pwd)/logs\n```\n\n## Logs\n\n- Application log: `logs/app.log`\n- LLM call logs: `logs/llm-YYYY-MM-DD.jsonl`\n\nLogs can also be viewed from the web management UI.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmark0725%2Fgo-agents-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmark0725%2Fgo-agents-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmark0725%2Fgo-agents-proxy/lists"}