DEDUPED Hot AI repos, turned into use cases Get the Monday 5

How to add a chat agent to a Go service with one model call with Zhizhi Agent Runtime

Wire an OpenAI-compatible model into a Go program with the runtime's Run method.

Short answer: Install the module: go get github.com/cocoyes/zhizhi-agent-runtime; then 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. All steps.

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

  1. Install the module: go get github.com/cocoyes/zhizhi-agent-runtime
  2. Create an openaicompat model from LLM_BASE_URL, LLM_API_KEY, and LLM_MODEL, then build the agent with zhizhi.New(zhizhi.WithModel(model)).
  3. Call agent.Run with a zhizhi.Request whose Input is the text to handle, and close the agent when done.
  4. Set the three environment variables and run the bundled chat example from the clone: go run ./examples/00-chat
  5. 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

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer