cli4api
v0.1.2
Published
OpenAI-compatible HTTP API for Google Antigravity CLI (agy) — wrap agy as a drop-in OpenAI endpoint
Maintainers
Readme
cli4api
Wrap Google Antigravity CLI (agy) as an OpenAI-compatible HTTP API.
Use any OpenAI SDK or tool (curl, OpenClaw, Cursor, etc.) to send prompts to agy's Gemini models — no API key needed, just agy's OAuth login.
Why
agy uses OAuth (not API keys), so you can't point standard OpenAI-compatible clients at it. cli4api bridges the gap:
[OpenAI client] → POST /v1/chat/completions → agy -p → GeminiRequirements
- Bun >= 1.2
- Antigravity CLI (
agy) installed and authenticated (agyonce interactively)
Install
npm install -g cli4apiOr run directly:
npx cli4apiUsage
# Start server (default port 8080)
cli4api
# Custom port and host
PORT=9090 HOST=127.0.0.1 cli4apiThen send requests:
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "Gemini 3.5 Flash (Medium)",
"messages": [{"role": "user", "content": "Say hello"}]
}'Streaming
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "Gemini 3.5 Flash (Medium)",
"messages": [{"role": "user", "content": "Say hello"}],
"stream": true
}'List models
curl http://localhost:8080/v1/modelsOpenAI Compatibility
| Endpoint | Method | Status |
|----------|--------|--------|
| /v1/chat/completions | POST | ✅ Streaming + non-streaming |
| /v1/models | GET | ✅ |
API
POST /v1/chat/completions
{
"model": "Gemini 3.5 Flash (Medium)",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "What is the capital of France?" }
],
"stream": false
}model— agy model name (default:Gemini 3.5 Flash (Medium))messages— array of{ role, content }objects (roles:system,user,assistant)stream— boolean, SSE streaming (default:false)
Development
git clone <repo> && cd cli4api
bun install
bun run dev # start server with hot reload
bun test # run tests
bun run build # bundle to dist/
bun run typecheckHow it works
cli4api spawns agy -p as a subprocess for each request, captures stdout, and wraps the response in OpenAI chat completion format. Session continuation uses agy's --conversation flag. Streaming is simulated by splitting the response into word-sized SSE chunks.
License
MIT
