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.
You only need three things to run the first request.
Create or copy a LinkHarbor API key from your workspace.
Choose a LinkHarbor platform model ID, for example google/gemini-2.5-flash.
When the model ID is placed in the URL path, encode / as %2F.
Use the LinkHarbor API host with Gemini-style model action paths. The model segment is the LinkHarbor platform model ID.
https://api.linkharbor.ai/v1beta/models/{model}:generateContentSend a non-streaming Gemini-style content generation request.
google/gemini-2.5-flashUse the platform model ID in the path. Encode slashes before sending the request.
Gemini-compatible calls should use x-goog-api-key and JSON content type.
x-goog-api-key: YOUR_API_KEY
Content-Type: application/jsonAuthorization: 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.
Copy this request, replace YOUR_API_KEY, and run it from a terminal. A successful response returns candidates and usageMetadata.
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" }
]
}
]
}'The first request only needs contents. Add generationConfig and tools later when your app needs more control.
contentsarrayRequired. The conversation content you send to the model.
partsarrayText, image, audio, or other Gemini-style content blocks inside each message.
generationConfigobjectOptional settings such as temperature, maxOutputTokens, topP, and stopSequences.
tools / toolConfigobjectOptional function-calling definitions and tool behavior settings.
{
"contents": [
{
"role": "user",
"parts": [
{ "text": "Reply only OK" }
]
}
],
"generationConfig": {
"temperature": 0.7,
"maxOutputTokens": 1024
}
}For most apps, read the first candidate text and track usageMetadata for token accounting.
candidates[0].content.parts[0].textstringThe model text output returned by the first candidate.
usageMetadataobjectToken usage for the request, including prompt, output, and total token counts.
finishReasonstringWhy the model stopped generating, such as STOP or a safety-related reason.
request_idstringReturned on errors to help support and debugging workflows.
{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{ "text": "OK" }
]
},
"finishReason": "STOP",
"index": 0
}
],
"usageMetadata": {
"promptTokenCount": 7,
"candidatesTokenCount": 1,
"totalTokenCount": 8
}
}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" }
]
}
]
}'A few habits make Gemini-compatible migrations easier to debug and safer to operate.
It matches Gemini API conventions and keeps this integration separate from OpenAI-compatible Bearer requests.
Encode / as %2F in platform model IDs before placing them in the URL path.
For this gateway, direct REST calls are more predictable than trying to repoint the official Gemini SDK.
Quick answers for common Gemini-compatible setup issues.
Find platform model IDs to place in Gemini-compatible paths.
View modelsUse OpenAI-compatible SDKs and Chat Completions clients.
View setupConfigure Claude-style SDKs and agent tools against LinkHarbor.
View setup