Gemini API

A simple REST API for text generation, streaming responses, chats, Gems, files, and research.

Open Swagger docsOpen ReDocBrowser login

Quick start

Start the service, authenticate through the local browser page if needed, then call the API from your application. Authentication cookies are managed by the persisted browser session.

curl -X POST http://127.0.0.1:8432/generate \
  -H 'Content-Type: application/json' \
  -d '{"prompt":"Explain async Python in three sentences."}'

Common endpoints

POST /generate

Generate a complete response from one prompt.

POST /generate/stream

Receive newline-delimited JSON chunks as the response is generated.

POST /chat/start/json

Start a persistent chat and optionally send its first message.

POST /chat/{chat_id}/message/json

Continue an existing chat conversation.

GET /models

List models available to the authenticated account.

GET /health

Check service and browser-client status.

Python example

import requests

response = requests.post(
    "http://127.0.0.1:8432/generate",
    json={"prompt": "Give me five names for a coffee shop."},
    timeout=300,
)
response.raise_for_status()
print(response.json()["text"])

Chat example

curl -X POST http://127.0.0.1:8432/chat/start/json \
  -H 'Content-Type: application/json' \
  -d '{"message":"You are a concise coding assistant."}'

curl -X POST http://127.0.0.1:8432/chat/CHAT_ID/message/json \
  -H 'Content-Type: application/json' \
  -d '{"message":"Explain dependency injection."}'

Streaming

Streaming endpoints return application/x-ndjson. Read one JSON object per line.

curl -N -X POST http://127.0.0.1:8432/generate/stream \
  -H 'Content-Type: application/json' \
  -d '{"prompt":"Write a short poem about APIs."}'

Keep this service bound to localhost or protect it with TLS and authentication before exposing it to a network. Do not expose browser or API credentials.