DEV Community

仪袁韶
仪袁韶

Posted on Originally published at tidelink.xyz

One OpenAI-compatible endpoint for CrewAI, AutoGen, PydanticAI, LlamaIndex and DSPy

Agent frameworks · one endpoint

One OpenAI-compatible endpoint for CrewAI, AutoGen, PydanticAI, LlamaIndex and DSPy

Every agent framework speaks the OpenAI SDK. That means you can point all of them at a single OpenAI-compatible base URL and stop juggling provider keys. Here is the copy-paste code for each — and why a managed endpoint beats standing up your own proxy.

Agent frameworks do not really have opinions about providers. Under the hood, CrewAI, AutoGen, PydanticAI, LlamaIndex, DSPy and Instructor all talk to an OpenAI-shaped /v1/chat/completions endpoint. The "OpenAI-native" feeling is just LangChain's OpenAI client — which means the whole framework re-points with one config value, one env var, or one constructor argument.

So instead of wiring each framework to OpenAI, then Anthropic, then a Chinese model provider, you point them all at one OpenAI-compatible gateway. You get one key, one bill, and multi-model failover without touching framework code again.

The base_url trick, framework by framework

Below, https://tidelink.xyz/v1 is the example gateway. Swap it for any OpenAI-compatible endpoint. All snippets are runnable as-is.

Plain OpenAI SDK

from openai import OpenAI

client = OpenAI(
    base_url="https://tidelink.xyz/v1",
    api_key="sk_live_xxxxxxxxxxxxxxxx",
)
resp = client.chat.completions.create(
    model="glm-5.3-flash",
    messages=[{"role":"user","content":"Draft a 3-bullet standup update."}],
)
print(resp.choices[0].message.content)

PydanticAI

from openai import AsyncOpenAI
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.openai import OpenAIProvider

client = AsyncOpenAI(
    base_url="https://tidelink.xyz/v1",
    api_key="sk_live_xxxxxxxxxxxxxxxx",
)
model = OpenAIChatModel("glm-5.3-flash", provider=OpenAIProvider(openai_client=client))
agent = Agent(model)
print(agent.run_sync("ping").output)

LlamaIndex

from llama_index.llms.openai_like import OpenAILike

llm = OpenAILike(
    model="glm-5.3-flash",
    api_base="https://tidelink.xyz/v1",
    api_key="sk_live_xxxxxxxxxxxxxxxx",
    is_chat_model=True,
    is_function_calling_model=True,
)

CrewAI

from crewai import LLM, Agent, Crew, Task

llm = LLM(
    model="openai/glm-5.3-flash",   # keep the openai/ prefix
    base_url="https://tidelink.xyz/v1",
    api_key="sk_live_xxxxxxxxxxxxxxxx",
)
agent = Agent(role="Greeter", goal="Greet briefly.", backstory="Concise.", llm=llm)
task = Task(description="ping", expected_output="A short greeting.", agent=agent)
print(Crew(agents=[agent], tasks=[task]).kickoff())

Instructor (structured output)

import instructor
from openai import OpenAI
from pydantic import BaseModel

client = instructor.from_openai(OpenAI(
    base_url="https://tidelink.xyz/v1",
    api_key="sk_live_xxxxxxxxxxxxxxxx",
))

class Out(BaseModel):
    title: str
    priority: int

out = client.chat.completions.create(
    model="glm-5.3-flash",
    response_model=Out,
    messages=[{"role":"user","content":"Summarize this ticket: DB is down, sev1."}],
)
print(out)

Anything built on LiteLLM (AutoGen, DSPy, LangChain)

These route through LiteLLM, so prefix the model id with openai/ and pass the base URL. The openai/ prefix is the gotcha — without it the framework matches a native provider and ignores your base_url.

# AutoGen / DSPy / LangChain all accept this shape
llm = SomeLLM(
    model="openai/glm-5.3-flash",
    base_url="https://tidelink.xyz/v1",
    api_key="sk_live_xxxxxxxxxxxxxxxx",
)

Why a managed endpoint, not your own proxy

You could stand up LiteLLM or another proxy yourself. The software is free; the operation is not. A gateway that stays correct under real traffic means key rotation, rate-limit backoff, failover, uptime alerts, and a 3am page — every week. A managed OpenAI-compatible endpoint hands you the same single base URL with none of that:

You get Self-hosted proxy Managed endpoint
One base_url for every framework You wire it Included
Multi-model failover You build it Included
Server to patch & keep online You None
Invoices for your clients You stitch it Included
SLA / someone to page None Contracted
Signup without a +86 phone number Varies Yes

Get a free TideLink API key — call GLM, Qwen, DeepSeek and more through one OpenAI-compatible endpoint: https://tidelink.xyz/dashboard.html?cid=devto

Top comments (0)