Claude SDK Integration
Connect to FIM Gate with the official Anthropic SDKs, covering Python, Node.js, Java, Go, and Ruby.
FIM Gate is compatible with the Anthropic Messages API protocol. Point the official Anthropic SDK's base URL at FIM Gate and call Claude models the way you already know.
| Setting | Value |
|---|---|
| Base URL | https://api.gate.fim.ai |
| API key | Created in the FIM Gate Console (referred to as $FIM_API_KEY below) |
Note: this compatibility endpoint is only for calling Claude models. For other models, use the OpenAI SDK integration or each provider's native API.
Configuring the API key
Anthropic SDKs in every language read the ANTHROPIC_API_KEY environment variable by default. Manage your key via environment variables instead of putting it in code:
# macOS / Linux
export ANTHROPIC_API_KEY="$FIM_API_KEY"# Windows
setx ANTHROPIC_API_KEY "$FIM_API_KEY"Python
Install the official SDK:
pip install anthropicPoint it at FIM Gate via the base_url parameter:
import os
import anthropic
client = anthropic.Anthropic(
api_key=os.getenv("ANTHROPIC_API_KEY"),
base_url="https://api.gate.fim.ai",
)
message = client.messages.create(
model="claude-opus-4-20250514",
max_tokens=1000,
system="You are a concise science writer.",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "Why is seawater salty?"},
],
}
],
)
print(message.content)Run python main.py to see the result.
Node.js
pnpm add @anthropic-ai/sdkPass baseURL when constructing the client:
import Anthropic from "@anthropic-ai/sdk";
const anthropic = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
baseURL: "https://api.gate.fim.ai",
});
const message = await anthropic.messages.create({
model: "claude-opus-4-20250514",
max_tokens: 1000,
system: "You are a concise science writer.",
messages: [
{
role: "user",
content: [{ type: "text", text: "Why is seawater salty?" }],
},
],
});
console.log(message);Save it as main.mjs and run node main.mjs (same for Deno and Bun).
Java
Add the Maven dependency:
<dependency>
<groupId>com.anthropic</groupId>
<artifactId>anthropic-java</artifactId>
<version>2.2.0</version>
</dependency>The Java SDK's fromEnv() reads the ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, and ANTHROPIC_BASE_URL environment variables. To connect to FIM Gate, set:
export ANTHROPIC_BASE_URL="https://api.gate.fim.ai"import com.anthropic.client.AnthropicClient;
import com.anthropic.client.okhttp.AnthropicOkHttpClient;
import com.anthropic.models.messages.Message;
import com.anthropic.models.messages.MessageCreateParams;
import com.anthropic.models.messages.Model;
AnthropicClient client = AnthropicOkHttpClient.fromEnv();
MessageCreateParams params = MessageCreateParams.builder()
.model(Model.CLAUDE_SONNET_4_20250514)
.maxTokens(1024L)
.addUserMessage("Why is seawater salty?")
.build();
Message message = client.messages().create(params);Go
go get github.com/anthropics/anthropic-sdk-goPoint it at FIM Gate via option.WithBaseURL (this option reads the ANTHROPIC_BASE_URL environment variable by default):
package main
import (
"context"
"fmt"
"github.com/anthropics/anthropic-sdk-go"
"github.com/anthropics/anthropic-sdk-go/option"
)
func main() {
client := anthropic.NewClient(
option.WithAPIKey("$FIM_API_KEY"), // reads the ANTHROPIC_API_KEY environment variable by default
option.WithBaseURL("https://api.gate.fim.ai"),
)
message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
Model: anthropic.ModelClaudeSonnet4_20250514,
MaxTokens: 1024,
Messages: []anthropic.MessageParam{
anthropic.NewUserMessage(anthropic.NewTextBlock("Why is seawater salty?")),
},
})
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", message.Content)
}Ruby
The official Ruby library requires Ruby 3.2.0 or later. HTTP transport is built on the standard library's net/http, with connection pooling provided by the connection_pool gem. Add to your Gemfile:
gem "anthropic", "~> 1.2.0"require "bundler/setup"
require "anthropic"
anthropic = Anthropic::Client.new(
api_key: ENV["ANTHROPIC_API_KEY"],
base_url: "https://api.gate.fim.ai"
)
message = anthropic.messages.create(
model: :"claude-sonnet-4-20250514",
max_tokens: 1024,
messages: [{ role: "user", content: "Why is seawater salty?" }]
)
puts(message.content)