apixly.ai

Gemini API

Gemini-compatible generateContent API. Works with the Gemini CLI. Auth uses the x-goog-api-key header. Requires a key bound to a Gemini group.

Environment variables

Note the base URL env is the bare domain — the CLI appends /v1beta itself:

bash
export GOOGLE_GEMINI_BASE_URL="https://apixly.ai"
export GEMINI_API_KEY="YOUR_API_KEY"

generateContent

FieldMeaning
candidates[0].content.parts[]Reply parts — the text lives in parts[].text
finishReasonSTOP = finished normally
usageMetadataToken counts — the basis for billing
bash
curl "https://apixly.ai/v1beta/models/gemini-2.5-pro:generateContent" \
  -H "x-goog-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{"parts": [{"text": "Hello"}]}]
  }'
json
{
  "candidates": [
    {
      "content": {
        "parts": [{ "text": "Hello! How can I help?" }],
        "role": "model"
      },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": { "promptTokenCount": 4, "candidatesTokenCount": 12 }
}

Image generation

Gemini image models generate through the same generateContent endpoint:

The generated image comes back as base64 in parts[].inlineData.data — decode it and save according to mimeType. Editing returns the same shape.

bash
curl "https://apixly.ai/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
  -H "x-goog-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{"parts": [{"text": "A cat astronaut floating in space, digital art"}]}],
    "generationConfig": {"responseModalities": ["TEXT", "IMAGE"]}
  }'
json
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "inlineData": {
              "mimeType": "image/png",
              "data": "<BASE64_IMAGE_DATA>"
            }
          }
        ],
        "role": "model"
      },
      "finishReason": "STOP"
    }
  ]
}

Image editing

Send the source image inline as base64 together with the instruction:

bash
curl "https://apixly.ai/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
  -H "x-goog-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{"parts": [
      {"text": "Add a wizard hat to the cat"},
      {"inline_data": {"mime_type": "image/png", "data": "<BASE64_IMAGE>"}}
    ]}],
    "generationConfig": {"responseModalities": ["IMAGE"]}
  }'
json
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "inlineData": {
              "mimeType": "image/png",
              "data": "<BASE64_IMAGE_DATA>"
            }
          }
        ],
        "role": "model"
      },
      "finishReason": "STOP"
    }
  ]
}

Model-specific request contracts

Discover available IDs with GET /v1/models using your key. The public price catalog is not a guarantee of current routing. Existing valid requests need no changes; optional fields are model-specific.

Native API: /v1beta/models/{model}:generateContent; contents[].parts, systemInstruction, generationConfig and tools use the Gemini format. For SSE use :streamGenerateContent?alt=sse. :countTokens is a model/upstream-dependent token-count operation, not generation billing. OpenAI-format requests use /v1/chat/completions only with a key/route that exposes the model there.

ModelRequest contract
gemini-2.5-flash · gemini-2.5-pro · gemini-3-flash-preview · gemini-3-pro-preview · gemini-3.1-pro-preview · gemini-3.5-flash · gemini-3.6-flash · gemini-3.7-flash · gemini-3.8-flashgenerateContent · streamGenerateContent · countTokens