Ana içeriğe geç

AI Gateway Quickstart

Add an LLM Provider Connection

Connect Apinizer to at least one LLM provider — cloud (OpenAI, Anthropic, Azure, Vertex, Bedrock) or self-hosted (vLLM, Ollama, Hugging Face TGI). The connection stores the provider's credentials encrypted, so your application never handles the real key.

See LLM Providers and Connections for the full setup steps.

Point Your OpenAI SDK at Apinizer

Configure the OpenAI SDK (or any OpenAI-compatible client) with your gateway's base_url and your Apinizer credential key:

from openai import OpenAI

client = OpenAI(
api_key="your-apinizer-credential-key",
base_url="https://your-apinizer-gateway.com/api/ai/v1"
)

No other client-side changes are needed — the SDK talks to Apinizer exactly as it would talk to OpenAI directly.

Your proxy's AI Routing tab has an Endpoints panel that lets you copy the gateway address per environment and try it quickly through the Test Console via the Test button next to it — see Routing and Failover for details.

Send Your First (Streaming) Chat Completion
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello, Apinizer!"}],
stream=True
)

for chunk in response:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)

The response streams back chunk-by-chunk as it arrives from the provider — the same shape you'd get calling the provider directly, regardless of which provider actually served the request.

Next Steps