Skip to content

Gemini-compatible API ​

The Gemini-compatible route accepts Google-style generateContent requests and translates them to rout.my routing internally.

text
POST https://api.rout.my/compatible/v1beta/models/{model}:generateContent
POST https://api.rout.my/compatible/v1beta/models/{model}:streamGenerateContent

The /gemini/... alias is also available for clients that expect that prefix.

Authentication ​

Both styles are accepted:

http
Authorization: Bearer sk_your_key_here

or:

text
?key=sk_your_key_here

Generate content ​

bash
curl "https://api.rout.my/compatible/v1beta/models/provider%2Fmodel-id:generateContent?key=$ROUTMY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          { "text": "Write a short greeting." }
        ]
      }
    ]
  }'

If the client cannot include slashes in the path model name, use a short alias only when that alias is configured. The exact model ID from /v1/models is still the safest value for OpenAI-compatible endpoints.

Image output ​

For Gemini-style image generation, include IMAGE in responseModalities:

json
{
  "contents": [
    {
      "role": "user",
      "parts": [
        { "text": "Create a square icon of a blue glass cube." }
      ]
    }
  ],
  "generationConfig": {
    "responseModalities": ["IMAGE", "TEXT"],
    "imageConfig": {
      "aspectRatio": "1:1",
      "imageSize": "1K"
    }
  }
}

Put the prompt and any style instructions in contents[].parts[].text (or systemInstruction.parts[].text for shared instructions). Top-level prompt and style are not Gemini request fields. Set the aspect ratio and resolution in generationConfig.imageConfig, as shown above.

Both camelCase and snake_case field names are accepted, including system_instruction, generation_config, response_modalities, image_config, aspect_ratio, image_size, inline_data, and mime_type. Use one naming style consistently; populated camelCase fields take precedence if both are present.

Image references can use inlineData: {"mimeType": "image/png", "data": "<base64>"} or fileData: {"mimeType": "image/png", "fileUri": "https://example.com/reference.png"} (file_data / file_uri are also accepted). The provider must be able to access a referenced URL. For models routed through the Images API, references select image editing and all instruction/message text is joined into the prompt.

Generated images are returned as Gemini-style inlineData parts when available.

Streaming ​

text
POST /compatible/v1beta/models/{model}:streamGenerateContent

Streaming responses are sent as Server-Sent Events in Gemini-compatible shape.

Models list ​

Gemini-compatible clients can also call:

text
GET https://api.rout.my/compatible/v1/models

or:

text
GET https://api.rout.my/compatible/models

API documentation for rout.my.