Endpoint OpenAI-compat BYOK + auth obligatoria en /v1/* - #10
Merged
Conversation
…cación en /v1/* Dominio: - proxy_service: el routing de Claude Code ahora escribe ui_api_key como ANTHROPIC_API_KEY (antes proxy_api_key débil por defecto). Aplicación: - Nuevo api/openai_compat.py: POST /v1/chat/completions — reenvía al provider activo (directo a OpenAI-compat con model reescrito; vía litellm para Anthropic), streaming SSE verbatim, errores upstream relayed, registro de usage cuando el response lo trae. - main.py: registro del router. Infraestructura: - middleware/auth.py: /v1/* deja de ser público — exige ui_api_key (o proxy_api_key legado, solo en /v1, para clientes ya configurados). Cierra acceso anónimo desde LAN a /v1/messages. - CLAUDE.md: documentación del endpoint BYOK y la regla de auth. Pruebas: - test_openai_compat.py: 6 tests (resolve_target por tipo de provider, extra headers, auth requerida, reescritura de model, relay de errores). - test_auth_middleware.py: actualizados a la propiedad nueva (401 sin key en /v1, ui key OK, proxy key solo /v1, /api no acepta proxy key). Cobertura global del proyecto: suite backend 101 passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resumen
POST /v1/chat/completions: superficie OpenAI-compatible sobre el provider activo — agrega bipolar-code como proveedor BYOK en VS Code Copilot Chat, Cursor, Cline, Continue (URL + API key)./v1/*era público — cualquiera en la LAN podía usar/v1/messagessin key. Ahora exigeui_api_key(oproxy_api_keylegado solo en/v1para clientes ya configurados). El routing de Claude Code escribe ahora elui_api_keyfuerte.Test plan
🤖 Generated with Claude Code