{"id":44932352,"url":"https://github.com/ongoingai/gateway","last_synced_at":"2026-02-24T12:00:32.928Z","repository":{"id":339087317,"uuid":"1160400824","full_name":"ongoingai/gateway","owner":"ongoingai","description":"Headless, OpenAI-compatible AI gateway in Go. Multi-tenant auth, tracing, cost tracking, rate limits, and optional PII redaction. Single binary, self-hosted, audit-ready by design.","archived":false,"fork":false,"pushed_at":"2026-02-22T08:03:58.000Z","size":16763,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-02-22T13:57:53.226Z","etag":null,"topics":["ai-gateway","audit-logs","cost-tracking","go","golang","llm-gateway","observability","openai-compatible","opentelemetry","pii-redaction","policy-enforcement","privacy","rate-limiting","security","tracing"],"latest_commit_sha":null,"homepage":"https://docs.ongoing.ai/gateway","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ongoingai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-02-17T22:29:10.000Z","updated_at":"2026-02-22T04:59:19.000Z","dependencies_parsed_at":"2026-02-19T07:00:47.426Z","dependency_job_id":null,"html_url":"https://github.com/ongoingai/gateway","commit_stats":null,"previous_names":["ongoingai/gateway"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/ongoingai/gateway","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ongoingai%2Fgateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ongoingai%2Fgateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ongoingai%2Fgateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ongoingai%2Fgateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ongoingai","download_url":"https://codeload.github.com/ongoingai/gateway/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ongoingai%2Fgateway/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29741255,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T07:44:07.782Z","status":"ssl_error","status_checked_at":"2026-02-23T07:44:07.432Z","response_time":90,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ai-gateway","audit-logs","cost-tracking","go","golang","llm-gateway","observability","openai-compatible","opentelemetry","pii-redaction","policy-enforcement","privacy","rate-limiting","security","tracing"],"created_at":"2026-02-18T06:03:54.122Z","updated_at":"2026-02-24T12:00:32.908Z","avatar_url":"https://github.com/ongoingai.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OngoingAI Gateway\n\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)\n[![Go](https://img.shields.io/badge/Go-1.23+-00ADD8?logo=go\u0026logoColor=white)](https://go.dev)\n[![Release](https://img.shields.io/github/v/release/ongoingai/gateway)](https://github.com/ongoingai/gateway/releases)\n\n**Open-source AI gateway for tracing, cost visibility, and audit-ready logs — with minimal overhead.**\n\nOngoingAI Gateway runs in front of your AI providers so every request is **visible, attributable, and reproducible** — without changing your code. Works with OpenAI, Anthropic, and OpenAI-compatible APIs.\n\n### Why it exists\n\nAI calls are production traffic, but most teams can't answer the questions that matter:\n\n- Which models are being used — and by what service, key, or workspace?\n- What did it cost per route, per team, or per environment?\n- What changed when latency spiked, errors started, or spend jumped?\n- Can we reproduce a request for debugging or audit?\n\nOngoingAI Gateway gives you a **provider-agnostic request log** with **privacy-first defaults**: tokens, latency, cost, and key hashes are always captured; request/response bodies are opt-in.\n\n---\n\n## Quickstart\n\n### 1) Install and start the gateway\n\n```bash\ncurl -fsSL https://ongoing.ai/install.sh | sh\nongoingai serve\n```\n\n### 2) Point SDKs and CLI tools at the gateway\n\n```bash\neval \"$(ongoingai shell-init)\"\n```\n\nOr set manually:\n\n```bash\nexport OPENAI_BASE_URL=http://localhost:8080/openai/v1\nexport ANTHROPIC_BASE_URL=http://localhost:8080/anthropic\n```\n\n### 3) Send requests through both providers\n\n```bash\ncurl http://localhost:8080/openai/v1/chat/completions \\\n  -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"model\":\"gpt-4o-mini\",\"messages\":[{\"role\":\"user\",\"content\":\"Reply with ok\"}]}'\n\ncurl http://localhost:8080/anthropic/v1/messages \\\n  -H \"x-api-key: $ANTHROPIC_API_KEY\" \\\n  -H \"anthropic-version: 2023-06-01\" \\\n  -H \"content-type: application/json\" \\\n  -d '{\"model\":\"claude-sonnet-4-latest\",\"max_tokens\":128,\"messages\":[{\"role\":\"user\",\"content\":\"Reply with ok\"}]}'\n```\n\n### 4) Stop the gateway and print an offline report\n\n```bash\n# Stop ongoingai serve (Ctrl+C), then run:\nongoingai report\nongoingai debug last\n```\n\n`ongoingai report` and `ongoingai debug last` read configured storage directly, so they work even when the server is not running.\n\n### Alternative start modes\n\n**Docker:**\n\n```bash\ndocker run --rm -p 8080:8080 \\\n  -v \"$(pwd)/data:/app/data\" \\\n  ghcr.io/ongoingai/gateway:latest\n```\n\n**Build from source:**\n\n```bash\ngit clone https://github.com/ongoingai/gateway.git\ncd gateway \u0026\u0026 make build\n./bin/ongoingai serve\n```\n\n---\n\n## Features\n\n**Provider Agnostic** — Works with OpenAI, Anthropic, and any OpenAI-compatible API. No vendor lock-in.\n\n**Zero-Config Start** — Single binary, embedded SQLite, no external dependencies. Running in under 30 seconds.\n\n**Full Trace Capture** — Every request logged with model, tokens, latency, cost, and API key hash. Streaming is proxied in real time with minimal overhead.\n\n**HTTP Analytics API** — Query traces, usage, cost, model stats, and key activity via stable JSON endpoints.\n\n**Reproducible Calls** — Trace metadata always captures model, tokens, latency, cost, and route context. Enable body capture for full payload-level replay.\n\n**Privacy First** — Request/response body logging is off by default and opt-in. API keys are hashed, never stored in plain text.\n\n**PII Redaction** — Configurable redaction modes for storage and upstream traffic, with scoped policies per workspace or provider.\n\n**Broad Compatibility** — Most tools that support OpenAI/Anthropic base URL configuration work via environment variables, with no plugins required.\n\n---\n\n## How Auth Works\n\n**Default mode:** your tools still hold the provider keys. OngoingAI Gateway forwards `OPENAI_API_KEY` / `ANTHROPIC_API_KEY` and stores only hashed key identifiers in traces.\n\n**Team gateway keys (optional):** Enable `auth.enabled` to require gateway authentication on proxy and analytics routes. Gateway tokens are passed via `X-OngoingAI-Gateway-Key` and are used only for gateway authorization (RBAC + tenant identity). Provider API keys are still supplied by the client and are never stored by OngoingAI.\n\nSee `AUTHORIZATION.md` for the resource/action/scope policy and role-permission matrix.\n\n---\n\n## Request Flow\n\n```mermaid\nflowchart LR\n    A[\"Client SDK/CLI\"] --\u003e B[\"Auth Middleware\"]\n    B --\u003e C[\"Body Capture Middleware\"]\n    C --\u003e D[\"Reverse Proxy Router\"]\n    D --\u003e E[\"Upstream Provider API\"]\n    C --\u003e F[\"Trace Builder\"]\n    F --\u003e G[\"Async Trace Writer (bounded queue)\"]\n    G --\u003e H[\"Trace Store (SQLite/Postgres)\"]\n```\n\n- Gateway auth is enforced before any provider forwarding.\n- Provider credentials are passed through upstream; gateway auth headers are stripped.\n- Trace writes are asynchronous so proxy response latency is not gated on storage.\n\n---\n\n## Security \u0026 Privacy\n\n- **API keys:** Forwarded to the upstream provider, never stored. Only hashed identifiers are kept in traces.\n- **Request/response bodies:** Off by default. Opt in with `capture_bodies: true` and cap size via `body_max_size`.\n- **Metadata:** Always captured (model, tokens, latency, cost) regardless of body capture settings.\n- **Storage:** SQLite file stored locally. Ensure appropriate file permissions on `data/ongoingai.db`.\n- **Gateway auth:** Optional team/role-based key auth is available via config and should be enabled for shared/team deployments.\n\n---\n\n## Usage\n\n### With AI CLI Tools\n\n```bash\n# Shell initialization (add to .bashrc / .zshrc)\neval \"$(ongoingai shell-init)\"\n\n# Now use any tool normally\nclaude-code \"refactor the auth module\"\ncodex \"write integration tests\"\naider --model gpt-4o\n```\n\n### Wrap Command\n\nRun any command through the gateway without changing your environment:\n\n```bash\nongoingai wrap -- claude-code \"fix the bug in main.go\"\nongoingai wrap -- python my_ai_script.py\n```\n\n### With SDKs\n\n```python\n# OpenAI\nfrom openai import OpenAI\nclient = OpenAI(base_url=\"http://localhost:8080/openai/v1\")\nresponse = client.chat.completions.create(\n    model=\"gpt-4o\",\n    messages=[{\"role\": \"user\", \"content\": \"Hello\"}]\n)\n\n# Anthropic\nimport anthropic\nclient = anthropic.Anthropic(base_url=\"http://localhost:8080/anthropic\")\nmessage = client.messages.create(\n    model=\"claude-sonnet-4-latest\",\n    max_tokens=1024,\n    messages=[{\"role\": \"user\", \"content\": \"Hello\"}]\n)\n```\n\n---\n\n## Compatibility\n\nWorks automatically with any tool that supports custom base URLs:\n\n| Tool | Env Var / Setting | Value |\n|------|-------------------|-------|\n| Claude Code | `ANTHROPIC_BASE_URL` | `http://localhost:8080/anthropic` |\n| OpenAI Codex CLI | `OPENAI_BASE_URL` | `http://localhost:8080/openai/v1` |\n| Aider | `OPENAI_API_BASE` or `--openai-api-base` | `http://localhost:8080/openai/v1` |\n| Continue (VS Code) | `apiBase` in config | `http://localhost:8080/openai/v1` |\n| LangChain | `base_url` on LLM client | `http://localhost:8080/openai/v1` |\n| Custom apps | Set base URL on any OpenAI/Anthropic SDK | See above |\n\n**Note:** OpenAI-compatible tools generally expect `/v1` in the base URL. Anthropic SDKs do not.\n\n---\n\n## Configuration\n\nOngoingAI Gateway works with zero configuration. For customization, create `ongoingai.yaml`:\n\n```yaml\nserver:\n  port: 8080\n  host: 0.0.0.0\n\nstorage:\n  driver: sqlite                # sqlite (default) | postgres\n  path: ./data/ongoingai.db     # SQLite path\n  # dsn: postgres://...         # Postgres connection string\n\nproviders:\n  openai:\n    upstream: https://api.openai.com\n    prefix: /openai\n  anthropic:\n    upstream: https://api.anthropic.com\n    prefix: /anthropic\n\ntracing:\n  capture_bodies: false         # Off by default\n  body_max_size: 1048576        # 1MB default\n\nauth:\n  enabled: false\n  header: X-OngoingAI-Gateway-Key\n```\n\nSchema migrations for SQLite and Postgres are embedded in the binary and applied automatically at startup.\n\nFor the full configuration reference (PII redaction, OpenTelemetry, gateway keys, env overrides), see the [Configuration Reference](https://docs.ongoing.ai/gateway/reference/config-reference).\n\n---\n\n## API\n\nQuery traces and analytics programmatically. Full schema: [`openapi/openapi.yaml`](openapi/openapi.yaml)\n\n```bash\nGET /api/traces?limit=50\u0026provider=anthropic   # List traces\nGET /api/traces/:id                           # Trace detail\nGET /api/analytics/usage?group_by=model       # Usage analytics\nGET /api/analytics/cost?group_by=provider     # Cost analytics\nGET /api/analytics/models                     # Model comparison\nGET /api/analytics/keys                       # Key analytics\nGET /api/health                               # Health check\n```\n\n---\n\n## Supported Providers\n\n| Provider | Streaming | Token Counting | Cost Estimation |\n|----------|-----------|----------------|-----------------|\n| OpenAI | Supported | Supported | Supported |\n| Anthropic | Supported | Supported | Supported |\n| OpenAI-Compatible | Supported | Supported | Manual config |\n\nComing soon: Google Gemini, Mistral, Cohere, local models (Ollama).\n\n## Storage Backends\n\n| Backend | Use Case | Status |\n|---------|----------|--------|\n| SQLite | Default. Zero setup, single file, embedded. | Supported |\n| PostgreSQL | Teams, higher throughput, existing infra. | Supported |\n| ClickHouse | Large-scale analytics, long retention. | Planned |\n\n---\n\n## Automated Releases\n\nRelease workflow details are documented in `release-automation.md`, including CI/build/test behavior, auto-tagging strategy, GitHub release + Docker publishing, and install-script hosting setup.\n\n---\n\n## Roadmap\n\nSee [ROADMAP.md](ROADMAP.md) for phase-based forward planning.\nSee [RELEASE_NOTES.md](RELEASE_NOTES.md) for completed milestones.\n\n**Now:** Core proxy, trace capture, SQLite + Postgres storage, OpenAI + Anthropic support, gateway authz.\n\n**Next:** Additional providers, policy controls, and operational hardening.\n\n**Later:** ClickHouse analytics, alerting, prompt replay, SDK instrumentation, enterprise features.\n\n---\n\n## Contributing\n\nContributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\nThe project is structured to make adding new providers straightforward — implement the `Provider` interface and register it. See `internal/providers/` for examples.\n\n---\n\n## Security\n\nSecurity policy and reporting guidance are in [SECURITY.md](SECURITY.md).\n\nCommunity expectations are defined in [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).\n\n---\n\n## License\n\nOngoingAI Gateway is licensed under the [Apache License 2.0](LICENSE).\n\n---\n\n## Links\n\n- **Docs:** https://docs.ongoing.ai/gateway\n- **Website:** https://ongoing.ai\n- **GitHub:** https://github.com/ongoingai/gateway\n- **X:** https://x.com/ongoingai\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fongoingai%2Fgateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fongoingai%2Fgateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fongoingai%2Fgateway/lists"}