LinkHarborLinkHarbor
ModelsPricingDocsContactStudioChat
Log inStart free
⌘K

Getting Started

  • Quick Start
  • Authentication

API Reference

  • List Models
  • Chat Completions
  • Error Codes

Advanced

  • OpenClaw
  • OpenAI-Compatible
  • Anthropic-Compatible
  • Gemini-Compatible
LinkHarborLinkHarbor

Unified AI model API gateway — access the world's leading LLMs in one place

Product

  • Models
  • Pricing

Resources

  • Docs
  • Contact

Legal

  • Privacy Policy
  • Terms of Service

© 2026 Future Intelligence Pte. Ltd. All rights reserved.

DocsGemini-Compatible API
Advanced

Gemini-Compatible API

Connect Gemini-style REST requests to LinkHarbor by changing the request URL, model path, and API key. Start with one generateContent request, then use the advanced reference when you need streaming, cached content, or extra actions.

Google's official Gemini SDK is not recommended for switching to a third-party gateway through base_url. For LinkHarbor, use the Gemini-compatible REST endpoint directly.

Before You Start

You only need three things to run the first request.

1

Create or copy a LinkHarbor API key from your workspace.

2

Choose a LinkHarbor platform model ID, for example google/gemini-2.5-flash.

3

When the model ID is placed in the URL path, encode / as %2F.

Request Setup

Use the LinkHarbor API host with Gemini-style model action paths. The model segment is the LinkHarbor platform model ID.

Endpoint

https://api.linkharbor.ai/v1beta/models/{model}:generateContent

Send a non-streaming Gemini-style content generation request.

Example model ID

google/gemini-2.5-flash

Use the platform model ID in the path. Encode slashes before sending the request.

Required Headers

Gemini-compatible calls should use x-goog-api-key and JSON content type.

Headers
x-goog-api-key: YOUR_API_KEY
Content-Type: application/json

Authorization: Bearer YOUR_API_KEY and ?key=YOUR_API_KEY are accepted as compatibility fallbacks, but x-goog-api-key is the recommended form for this page.

Run Your First Request

Copy this request, replace YOUR_API_KEY, and run it from a terminal. A successful response returns candidates and usageMetadata.

cURL
export LINKHARBOR_API_KEY="YOUR_API_KEY"

curl -sS "https://api.linkharbor.ai/v1beta/models/google%2Fgemini-2.5-flash:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $LINKHARBOR_API_KEY" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          { "text": "Reply only OK" }
        ]
      }
    ]
  }'

Understand the Request Body

The first request only needs contents. Add generationConfig and tools later when your app needs more control.

contentsarray

Required. The conversation content you send to the model.

partsarray

Text, image, audio, or other Gemini-style content blocks inside each message.

generationConfigobject

Optional settings such as temperature, maxOutputTokens, topP, and stopSequences.

tools / toolConfigobject

Optional function-calling definitions and tool behavior settings.

JSON
{
  "contents": [
    {
      "role": "user",
      "parts": [
        { "text": "Reply only OK" }
      ]
    }
  ],
  "generationConfig": {
    "temperature": 0.7,
    "maxOutputTokens": 1024
  }
}

Read the Response

For most apps, read the first candidate text and track usageMetadata for token accounting.

candidates[0].content.parts[0].textstring

The model text output returned by the first candidate.

usageMetadataobject

Token usage for the request, including prompt, output, and total token counts.

finishReasonstring

Why the model stopped generating, such as STOP or a safety-related reason.

request_idstring

Returned on errors to help support and debugging workflows.

JSON
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          { "text": "OK" }
        ]
      },
      "finishReason": "STOP",
      "index": 0
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 7,
    "candidatesTokenCount": 1,
    "totalTokenCount": 8
  }
}

Code Examples

The same request shown as cURL, JavaScript fetch, and Python requests.

curl -sS "https://api.linkharbor.ai/v1beta/models/google%2Fgemini-2.5-flash:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $LINKHARBOR_API_KEY" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          { "text": "Reply only OK" }
        ]
      }
    ]
  }'

Best Practices

A few habits make Gemini-compatible migrations easier to debug and safer to operate.

Prefer x-goog-api-key

It matches Gemini API conventions and keeps this integration separate from OpenAI-compatible Bearer requests.

Encode model IDs

Encode / as %2F in platform model IDs before placing them in the URL path.

Start with REST

For this gateway, direct REST calls are more predictable than trying to repoint the official Gemini SDK.

FAQ

Quick answers for common Gemini-compatible setup issues.

Should I use the official Google Gemini SDK with a custom base URL?
No. For the current LinkHarbor gateway, use direct REST calls to the Gemini-compatible endpoints.
Why does a model with / in the name fail?
Encode the slash as %2F in the path. For example, google/gemini-2.5-flash becomes google%2Fgemini-2.5-flash.
When should I use OpenAI-compatible Chat Completions instead?
Use /v1/chat/completions when your client only speaks OpenAI protocol. Use this Gemini-compatible page for Gemini REST and Gemini CLI workflows.

What's next

List Models

Find platform model IDs to place in Gemini-compatible paths.

View models

OpenAI-Compatible API

Use OpenAI-compatible SDKs and Chat Completions clients.

View setup

Anthropic-Compatible API

Configure Claude-style SDKs and agent tools against LinkHarbor.

View setup
Need help?Contact support →