{
 "schema_version": 1,
 "generated": "2026-10-26",
 "id": "cocoyes-zhizhi-agent-runtime--add-chat-agent-to-go-service",
 "repo": "cocoyes/zhizhi-agent-runtime",
 "repo_url": "https://github.com/cocoyes/zhizhi-agent-runtime",
 "repo_slug": "cocoyes-zhizhi-agent-runtime",
 "title": "Add a chat agent to a Go service with one model call",
 "page_title": "How to add a chat agent to a Go service with one model call with Zhizhi Agent Runtime",
 "summary": "Wire an OpenAI-compatible model into a Go program with the runtime's Run method.",
 "who": "A Go backend developer who wants a simple LLM-backed request handler inside an existing service.",
 "problem": "Calling a chat endpoint directly gives you no structure around tools, retries, or traces. You want a small agent object that wraps the model call.",
 "outcome": "A Go program that sends a request through the agent and prints the text of the response.",
 "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."
 ],
 "agent_prompt": "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.",
 "agents": [
  "any"
 ],
 "difficulty": "Intermediate",
 "time": "30 minutes",
 "basis": "readme",
 "caveat": "The adapter calls {LLM_BASE_URL}/chat/completions, so the provider must expose that path or the calls will fail.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "go",
 "requirements": [
  "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"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.9,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/cocoyes-zhizhi-agent-runtime/add-chat-agent-to-go-service/",
 "md": "https://dedupedai.com/use-cases/cocoyes-zhizhi-agent-runtime/add-chat-agent-to-go-service/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/cocoyes-zhizhi-agent-runtime--add-chat-agent-to-go-service.json",
 "api_version": "v1"
}
