Summary
Add an explicit custom text-provider contract while preserving AI Gateway as the default:
--provider openai-compatiblefor Chat Completions--provider openai-responsesfor Responses streaming--base-url,--api-key-env, optional--models-url, and existing--model- equivalent
AI_CLI_*environment variables - fixed, non-secret attribution headers from
PAPERCLIP_AGENT_ID/PAPERCLIP_RUN_ID - fail closed for image, video, speech, and transcription in custom modes
- redact configured keys, bearer auth, and URL userinfo from errors
The existing package metadata declares Apache-2.0, but the repository and npm tarball omit the license text. The proposal also adds the canonical Apache-2.0 LICENSE to the repository and packed CLI.
Motivation
Self-hosted routers and local model gateways need a supported text path that cannot silently fall back to Vercel AI Gateway. API-key environment indirection keeps keys out of command history, and custom model listing should use the selected endpoint rather than contacting Gateway.
Implementation notes
A reviewed reference implementation is available in valkyriweb/ai-cli PR 1: https://github.com/valkyriweb/ai-cli/pull/1
Exact reviewed head: 7803a8f7a53fa37d113adb0b469c76c988166165
The provider selection is centralized in src/lib/provider.ts; model discovery dispatches by provider; Responses mode uses streaming because some compatible routers require stream: true. Gateway code paths and defaults are unchanged.
The bundled ai-cli skill is extended rather than adding a competing skill, with a focused Agent Skill authoring reference.
Testing notes
- deterministic fetch tests assert exact
/models,/chat/completions, and/responsesURLs - assert allowlisted headers and no
ai-gateway.vercel.shrequest in custom modes - unsupported modality and redaction tests
- full typecheck, format, lint, tests, and build
- real synthetic Responses smoke through a self-hosted router using a cheap text model
- independent exact-head review and TruffleHog scan are clean
Risks or tradeoffs
Custom modes intentionally support text only. OpenAI-compatible model metadata is less rich than Gateway metadata, so pricing/provider endpoint details are unavailable. Responses mode streams internally and collects the final text to preserve current CLI output semantics.
Co-contributor credit
Yes, credit @valkyriweb.
Checklist
- I searched existing issues for duplicates.
- I understand pull requests are limited to collaborators and maintainers will handle implementation.
Activity
0No activity yet.