Who it is forA Go backend developer who wants a simple LLM-backed request handler inside an existing service.
The problemCalling a chat endpoint directly gives you no structure around tools, retries, or traces. You want a small agent object that wraps the model call.
The outcomeA Go program that sends a request through the agent and prints the text of the response.
What you need first
- Go 1.25 or newer
- An OpenAI-compatible Chat Completions endpoint with a base URL, API key, and model name
- A clone of the repo or a Go module that imports github.com/cocoyes/zhizhi-agent-runtime
Steps
- Install the module:
go get github.com/cocoyes/zhizhi-agent-runtime - Create an openaicompat model from LLM_BASE_URL, LLM_API_KEY, and LLM_MODEL, then build the agent with zhizhi.New(zhizhi.WithModel(model)).
- Call agent.Run with a zhizhi.Request whose Input is the text to handle, and close the agent when done.
- Set the three environment variables and run the bundled chat example from the clone:
go run ./examples/00-chat - Optionally set Thinking or ReasoningEffort in openaicompat.Config if your provider supports hybrid reasoning models.
Prompt for your agent
In a Go project, add github.com/cocoyes/zhizhi-agent-runtime and build an agent using openaicompat with LLM_BASE_URL, LLM_API_KEY, and LLM_MODEL. Expose a function that runs <request-text> through agent.Run and returns response.Text. Verify by running `go run ./examples/00-chat` from a clone and confirming a non-empty reply.
Caveat. The adapter calls {LLM_BASE_URL}/chat/completions, so the provider must expose that path or the calls will fail.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for cocoyes/zhizhi-agent-runtime and "Add a chat agent to a Go service with one model call"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer