Get up and running with the LinkHarbor API in minutes. Make your first AI-powered request with just a few lines of code.
Sign up for a free LinkHarbor account to get your API key. Your key grants access to models from OpenAI, Anthropic, Google, and more.
Choose the interface you want to use and install the matching SDK.
pip install anthropicpip install openaiExport your API key as an environment variable. Never hard-code it in your source code.
export OPENAI_API_KEY="YOUR_API_KEY"
export OPENAI_BASE_URL="https://api.linkharbor.ai/v1"Use either the Anthropic Messages API or the OpenAI-compatible chat completions endpoint with models from the LinkHarbor catalog.
from anthropic import Anthropic
import os
client = Anthropic(
base_url="https://api.linkharbor.ai/anthropic",
api_key=os.environ["ANTHROPIC_AUTH_TOKEN"]
)
message = client.messages.create(
model="your-model-name",
max_tokens=1024,
messages=[{"role": "user", "content": "What is the capital of France?"}]
)
print(message.content[0].text)from openai import OpenAI
import os
client = OpenAI(
base_url="https://api.linkharbor.ai/v1",
api_key=os.environ["OPENAI_API_KEY"]
)
response = client.chat.completions.create(
model="your-model-name",
messages=[{"role": "user", "content": "What is the capital of France?"}]
)
print(response.choices[0].message.content)Enable streaming to receive tokens as they're generated — ideal for chat interfaces with real-time feedback.
stream = client.chat.completions.create(
model="your-model-name",
messages=[{"role": "user", "content": "Write a haiku about APIs"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)You've made your first request. Explore the full API capabilities below.