SDK Reference
OpenAI SDK Compatibility
BazaarLink is fully compatible with the OpenAI Python and Node.js SDKs. Only two changes needed:
Before (OpenAI direct)
python
from openai import OpenAI
client = OpenAI(
api_key="sk-..."
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[...]
)After (BazaarLink)
python
from openai import OpenAI
client = OpenAI(
base_url="https://bazaarlink.ai/api/v1",
api_key="sk-bl-YOUR_API_KEY"
)
response = client.chat.completions.create(
model="openai/gpt-4o", # add provider/
messages=[...]
)That's it!
All other features — streaming, tool calling, structured output, async — work exactly the same. The only change is base_url, api_key, and adding the provider prefix to model IDs.
Python
Installation
bash
pip install openai
Synchronous
python
from openai import OpenAI
client = OpenAI(
base_url="https://bazaarlink.ai/api/v1",
api_key="sk-bl-YOUR_API_KEY",
)
response = client.chat.completions.create(
model="openai/gpt-4.1",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)Async
python
import asyncio
from openai import AsyncOpenAI
client = AsyncOpenAI(
base_url="https://bazaarlink.ai/api/v1",
api_key="sk-bl-YOUR_API_KEY",
)
async def main():
response = await client.chat.completions.create(
model="anthropic/claude-sonnet-4.6",
messages=[{"role": "user", "content": "Hello async world!"}],
)
print(response.choices[0].message.content)
asyncio.run(main())Streaming with async
python
async def stream_chat():
stream = await client.chat.completions.create(
model="deepseek/deepseek-chat",
messages=[{"role": "user", "content": "Tell me a story"}],
stream=True,
)
async for chunk in stream:
content = chunk.choices[0].delta.content
if content:
print(content, end="", flush=True)
asyncio.run(stream_chat())TypeScript / Node.js
Installation
bash
npm install openai
Basic Usage
typescript
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://bazaarlink.ai/api/v1",
apiKey: process.env.BAZAARLINK_API_KEY,
});
async function chat(message: string): Promise<string> {
const response = await client.chat.completions.create({
model: "openai/gpt-4.1",
messages: [{ role: "user", content: message }],
});
return response.choices[0].message.content ?? "";
}Streaming
typescript
const stream = await client.chat.completions.create({
model: "openai/gpt-4.1",
messages: [{ role: "user", content: "Tell me a story" }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}LangChain
Use BazaarLink with LangChain by configuring the OpenAI-compatible base URL.
python
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
base_url="https://bazaarlink.ai/api/v1",
api_key="sk-bl-YOUR_API_KEY",
model="anthropic/claude-sonnet-4.6",
)
response = llm.invoke("Explain BazaarLink in one sentence.")
print(response.content)LlamaIndex
Use BazaarLink in LlamaIndex RAG pipelines. LlamaIndex supports any OpenAI-compatible endpoint — just change two parameters.
python
from llama_index.llms.openai import OpenAI
from llama_index.core import Settings
Settings.llm = OpenAI(
model="openai/gpt-4.1",
api_base="https://bazaarlink.ai/api/v1",
api_key="sk-bl-YOUR_API_KEY",
)
# Now use LlamaIndex normally — it calls BazaarLink
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
documents = SimpleDirectoryReader("./docs").load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()
response = query_engine.query("What is this documentation about?")
print(response)Vercel AI SDK
Integrate the Vercel AI SDK with BazaarLink in your Next.js app. Supports streaming, tool calling, and structured output.
Installation
bash
npm install ai @ai-sdk/openai
typescript
import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";
const bazaarlink = createOpenAI({
baseURL: "https://bazaarlink.ai/api/v1",
apiKey: "sk-bl-YOUR_API_KEY",
});
const { text } = await generateText({
model: bazaarlink("openai/gpt-4.1"),
prompt: "Write a haiku about programming",
});
console.log(text);