Agentic Usage
Agent Frameworks
Use BazaarLink with popular agent frameworks. Since BazaarLink is OpenAI-compatible, most frameworks work out of the box — just set the base URL and API key.
Vercel AI SDK
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);CrewAI
from crewai import Agent, Task, Crew
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",
)
researcher = Agent(
role="Researcher",
goal="Research and summarize topics",
llm=llm,
)
task = Task(
description="Research the latest trends in AI agents",
agent=researcher,
)
crew = Crew(agents=[researcher], tasks=[task])
result = crew.kickoff()
print(result)AutoGen
from autogen import AssistantAgent, UserProxyAgent
config_list = [{
"model": "openai/gpt-4.1",
"base_url": "https://bazaarlink.ai/api/v1",
"api_key": "sk-bl-YOUR_API_KEY",
}]
assistant = AssistantAgent(
"assistant",
llm_config={"config_list": config_list},
)
user_proxy = UserProxyAgent(
"user_proxy",
human_input_mode="NEVER",
code_execution_config={"work_dir": "coding"},
)
user_proxy.initiate_chat(
assistant,
message="Write a Python function to calculate fibonacci numbers",
)Environment Variables
Most agent frameworks support configuration via environment variables:
# .env OPENAI_API_KEY=sk-bl-YOUR_API_KEY OPENAI_BASE_URL=https://bazaarlink.ai/api/v1
AI Agent Auto-Registration
BazaarLink's auto-registration endpoint lets AI agents self-register and obtain an API key in a single API call. The agent also generates a "claim link" for its human owner — the owner logs in, claims the key, and it transfers to their account.
Flow
Bot Self-Registration API
/api/v1/agents/registercurl -X POST https://bazaarlink.ai/api/v1/agents/register \
-H "Content-Type: application/json" \
-d '{"name": "MyBot"}'{
"api_key": "sk-bl-xxxxxxxxxxxxxxxx",
"credits": 0,
"claim_token": "xxxxxxxx",
"claim_expires": "2026-03-09T00:00:00.000Z",
"upgrade_url": "https://bazaarlink.ai/claim?token=xxxxxxxx",
"referral_code": "abc12345",
"base_url": "https://bazaarlink.ai/api/v1",
"docs": "https://bazaarlink.ai/llms.txt",
"message": "I registered an account on bazaarlink.ai..."
}Request Parameters
Usage Notes
- The API key has no trial credits after registration; the owner must claim it and top up manually
- claim_token is valid for 7 days; the link expires after that
- Each IP is limited to 1 registration per 24 hours
- After the owner claims, the key is automatically renamed to "BotName (claimed)"
- Referral codes allow both parties to earn bonus credits during future promotional periods
Observability & Tracing
Connect observability tools to gain full visibility into your AI API calls, latency, and token usage.
Helicone
import openai
client = openai.OpenAI(
base_url="https://gateway.helicone.ai/api/v1",
api_key="sk-bl-YOUR_API_KEY",
default_headers={
"Helicone-Auth": "Bearer hc-YOUR_HELICONE_KEY",
"Helicone-Target-URL": "https://bazaarlink.ai/api/v1",
},
)
response = client.chat.completions.create(
model="openai/gpt-4.1",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)LangSmith
import os
from openai import OpenAI
os.environ["LANGCHAIN_TRACING_V2"] = "true"
os.environ["LANGCHAIN_API_KEY"] = "ls-YOUR_LANGSMITH_KEY"
# Use BazaarLink via LangChain with tracing enabled
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
base_url="https://bazaarlink.ai/api/v1",
api_key="sk-bl-YOUR_API_KEY",
model="openai/gpt-4.1",
)
response = llm.invoke("Hello from LangSmith + BazaarLink!")
print(response.content)MCP Servers
Model Context Protocol (MCP) is an open standard that lets AI models connect to external tools and data sources. Through BazaarLink's MCP integration, you can give models access to custom tools.
How MCP Works
- Your application acts as an MCP host
- MCP servers provide tool definitions and data access
- Models call these tools through BazaarLink
- Results are returned to the model to generate the final response
Current Alternative
# Currently: use standard tool calling to connect external tools
import json
def get_weather(city: str) -> str:
# Your tool implementation
return f"The weather in {city} is 25°C."
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}]
response = client.chat.completions.create(
model="openai/gpt-4o",
messages=[{"role": "user", "content": "What's the weather in Taipei?"}],
tools=tools,
)
# Handle tool call
if response.choices[0].finish_reason == "tool_calls":
call = response.choices[0].message.tool_calls[0]
args = json.loads(call.function.arguments)
result = get_weather(**args)