FIM Gate Docs
Guide

Quickstart

The complete walkthrough from creating an API key to making your first request, covering the OpenAI, Claude, and Gemini calling conventions.

This page gets you from zero to your first request in a few minutes.

Step 1: Create an API key

  1. Sign in to the FIM Gate Console.
  2. Open the API key management page and create a new API key.
  3. Copy it and store it safely. The key is your request credential — if it leaks, disable it and create a new one immediately.

See API Keys & Tokens for detailed steps. In the examples below, $FIM_API_KEY refers to this key.

Step 2: Choose a model

The live model list and prices are on the pricing page. Just replace the model field in the examples with the model ID you want to use.

Step 3: Make a request

OpenAI-compatible API

Works with all models. The Base URL is https://api.gate.fim.ai/v1, and authentication uses the Authorization: Bearer request header.

Text chat
curl https://api.gate.fim.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $FIM_API_KEY" \
  -d '{
    "model": "gpt-4.1",
    "messages": [
      {"role": "user", "content": "Explain idempotency and give an HTTP example"}
    ]
  }'
Image understanding (image_url)
curl https://api.gate.fim.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $FIM_API_KEY" \
  -d '{
    "model": "gpt-4.1",
    "messages": [
      {
        "role": "user",
        "content": [
          {"type": "text", "text": "What is the main subject of this image?"},
          {"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}
        ]
      }
    ]
  }'
Built-in web search (web_search_options)
curl https://api.gate.fim.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $FIM_API_KEY" \
  -d '{
    "model": "gpt-4o-search-preview",
    "web_search_options": {},
    "messages": [
      {"role": "user", "content": "What notable AI developments happened in the past week?"}
    ]
  }'
Function calling (tools)
curl https://api.gate.fim.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $FIM_API_KEY" \
  -d '{
    "model": "gpt-4.1",
    "messages": [
      {"role": "user", "content": "Check the weather in Shanghai for tomorrow"}
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "query_weather",
          "description": "Query the weather forecast by city",
          "parameters": {
            "type": "object",
            "properties": {
              "city": {"type": "string", "description": "City name, e.g. Shanghai"},
              "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
            },
            "required": ["city"]
          }
        }
      }
    ],
    "tool_choice": "auto"
  }'

With the official SDKs, just point base_url at FIM Gate:

Python (openai library)
from openai import OpenAI

client = OpenAI(
    api_key="sk-...",  # your FIM Gate API key
    base_url="https://api.gate.fim.ai/v1",
)

resp = client.chat.completions.create(
    model="gpt-4.1",
    messages=[{"role": "user", "content": "Explain idempotency"}],
)
print(resp.choices[0].message.content)
Node.js (openai library)
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.FIM_API_KEY,
  baseURL: "https://api.gate.fim.ai/v1",
});

const resp = await client.chat.completions.create({
  model: "gpt-4.1",
  messages: [{ role: "user", content: "Explain idempotency" }],
});
console.log(resp.choices[0].message.content);

Claude native API

The endpoint is https://api.gate.fim.ai/v1/messages, authenticated with the x-api-key request header. Note: this entry point only accepts Claude-family models; use the OpenAI-compatible API for everything else.

Text chat
curl https://api.gate.fim.ai/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: $FIM_API_KEY" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Explain the TCP three-way handshake in three sentences"}
    ]
  }'
Image input (base64)
curl https://api.gate.fim.ai/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: $FIM_API_KEY" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "image",
            "source": {"type": "base64", "media_type": "image/jpeg", "data": "<BASE64>"}
          },
          {"type": "text", "text": "What is in this image?"}
        ]
      }
    ]
  }'

With the official Anthropic SDK, set base_url to https://api.gate.fim.ai — the SDK appends /v1/messages automatically:

Python (anthropic library)
import anthropic

client = anthropic.Anthropic(
    api_key="sk-...",  # your FIM Gate API key
    base_url="https://api.gate.fim.ai",
)

msg = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Explain the TCP three-way handshake in three sentences"}],
)
print(msg.content)

Gemini native API

The endpoint has the form https://api.gate.fim.ai/v1beta/models/{model}:generateContent, authenticated with the x-goog-api-key request header; for streaming, use :streamGenerateContent?alt=sse. This entry point only accepts Gemini-family models.

Text chat
curl -X POST "https://api.gate.fim.ai/v1beta/models/gemini-2.5-flash:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $FIM_API_KEY" \
  -d '{
    "contents": [
      {"role": "user", "parts": [{"text": "What is a Bloom filter?"}]}
    ]
  }'
Image input (inlineData)
curl -X POST "https://api.gate.fim.ai/v1beta/models/gemini-2.5-flash:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $FIM_API_KEY" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {"inlineData": {"mimeType": "image/png", "data": "<BASE64>"}},
          {"text": "Describe this image"}
        ]
      }
    ]
  }'

The Google GenAI SDK takes the Base URL via http_options:

Python (google-genai library)
from google import genai
from google.genai import types

client = genai.Client(
    api_key="sk-...",  # your FIM Gate API key
    http_options=types.HttpOptions(base_url="https://api.gate.fim.ai"),
)

resp = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="What is a Bloom filter?",
)
print(resp.text)

FAQ

Getting 401 / authentication failures? Make sure the key was copied in full (it starts with sk-) and the request header format is correct: Authorization: Bearer for the OpenAI-compatible API, x-api-key for Claude, and x-goog-api-key for Gemini.

Model not found? Check that the model ID matches the model list on the pricing page exactly. Also note that the Claude and Gemini native entry points only accept their own model families; for cross-family calls, always use https://api.gate.fim.ai/v1.

Entered the address in a client but can't connect? Different clients join paths differently. Try these three forms in order: https://api.gate.fim.ai, https://api.gate.fim.ai/v1, https://api.gate.fim.ai/v1/chat/completions.

Want streaming output? For the OpenAI-compatible API, add "stream": true to the request body; for the Gemini native API, switch to the :streamGenerateContent?alt=sse endpoint.