{"id":46456113,"url":"https://github.com/iamwavecut/gopenrouter","last_synced_at":"2026-03-06T01:54:02.319Z","repository":{"id":298454115,"uuid":"999883524","full_name":"iamwavecut/gopenrouter","owner":"iamwavecut","description":"An unofficial simple OpenRouter client in Go","archived":false,"fork":false,"pushed_at":"2025-08-19T19:45:18.000Z","size":45,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-19T21:29:49.159Z","etag":null,"topics":["go","openrouter"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamwavecut.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-11T00:10:35.000Z","updated_at":"2025-08-19T19:45:21.000Z","dependencies_parsed_at":"2025-06-11T07:40:39.011Z","dependency_job_id":"9c44c7ec-6cf9-4305-a414-7ae6110b8816","html_url":"https://github.com/iamwavecut/gopenrouter","commit_stats":null,"previous_names":["iamwavecut/gopenrouter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iamwavecut/gopenrouter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamwavecut%2Fgopenrouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamwavecut%2Fgopenrouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamwavecut%2Fgopenrouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamwavecut%2Fgopenrouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamwavecut","download_url":"https://codeload.github.com/iamwavecut/gopenrouter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamwavecut%2Fgopenrouter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30158253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T22:39:40.138Z","status":"ssl_error","status_checked_at":"2026-03-05T22:39:24.771Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","openrouter"],"created_at":"2026-03-06T01:54:01.392Z","updated_at":"2026-03-06T01:54:02.298Z","avatar_url":"https://github.com/iamwavecut.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gopenrouter\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/iamwavecut/gopenrouter.svg)](https://pkg.go.dev/github.com/iamwavecut/gopenrouter)\n[![Go Report Card](https://goreportcard.com/badge/github.com/iamwavecut/gopenrouter)](https://goreportcard.com/report/github.com/iamwavecut/gopenrouter)\n[![Go Version](https://img.shields.io/badge/go%20version-%3E=1.18-6e45e5.svg)](https://golang.org/)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\nAn unofficial Go client for the [OpenRouter API](https://openrouter.ai).\n\nThis library provides a comprehensive, `go-openai`-inspired interface for interacting with the OpenRouter API, giving you access to a multitude of LLMs through a single, unified client.\n\n## Credits\n\nThis library's design and structure are heavily inspired by the excellent [go-openai](https://github.com/sashabaranov/go-openai) library.\n\n## Key Differences from `go-openai`\n\nWhile this library maintains a familiar, `go-openai`-style interface, it includes several key features and fields specifically tailored for the OpenRouter API:\n\n- **Multi-Provider Models**: Seamlessly switch between models from different providers (e.g., Anthropic, Google, Mistral) by changing the `Model` string.\n- **Cost Tracking**: The `Usage` object in responses includes a `Cost` field, providing direct access to the dollar cost of a generation.\n- **Native Token Counts**: The `GetGeneration` endpoint provides access to `NativePromptTokens` and `NativeCompletionTokens`, giving you precise, provider-native tokenization data.\n- **Advanced Routing**: Use `Models` for fallback chains and `Route` for custom routing logic.\n- **Reasoning Parameters**: Control and request \"thinking\" tokens from supported models using the `Reasoning` parameters.\n- **Provider-Specific `ExtraBody`**: Pass custom, provider-specific parameters through the `ExtraBody` field for fine-grained control.\n- **Client Utilities**: Includes built-in methods to `ListModels`, `CheckCredits`, and `GetGeneration` stats directly from the client.\n\n## Installation\n\n```bash\ngo get github.com/iamwavecut/gopenrouter\n```\n\n## Usage\n\nFor complete, runnable examples, please see the [`examples/`](./examples) directory. A summary of available examples is below:\n\n| Feature                                                      | Description                                                                                     |\n| ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- |\n| [Basic Chat](./examples/chat)                                | Demonstrates the standard chat completion flow.                                                 |\n| [Streaming Chat](./examples/chat_stream)                     | Shows how to stream responses for real-time output.                                             |\n| [Vision (Images)](./examples/chat_vision)                    | Illustrates how to send image data using the `MultiContent` field for vision-enabled models.    |\n| [File Attachments](./examples/chat_file_attachment)          | Shows how to attach files (e.g., PDFs) for models that support file-based inputs.               |\n| [Prompt Caching](./examples/chat_caching)                    | Reduces cost and latency by using OpenRouter's explicit `CacheControl` for supported providers. |\n| [Automatic Caching (OpenAI)](./examples/chat_caching_openai) | Demonstrates OpenAI's automatic caching for large prompts, a cost-saving feature on OpenRouter. |\n| [Structured Outputs](./examples/structured_output)           | Enforces a specific JSON schema for model outputs, a powerful OpenRouter feature.               |\n| [Reasoning Tokens](./examples/chat_reasoning)                | Shows how to request and inspect the model's \"thinking\" process, unique to OpenRouter.          |\n| [Provider Extras](./examples/chat_extra_body)                | Uses the `ExtraBody` field to pass provider-specific parameters for fine-grained control.       |\n| [Tool Calling (History)](./examples/tool_call_loop)          | End-to-end tool-calling loop with full-history resend and tool result messages.                 |\n| [Logprobs](./examples/logprobs)                              | Request token logprobs and inspect per-token candidates.                                        |\n| [Streaming with Usage](./examples/stream_include_usage)      | Stream responses and receive a final usage chunk before [DONE].                                 |\n| [List Models](./examples/list_models)                        | A client utility to fetch the list of all models available on OpenRouter.                       |\n| [Check Credits](./examples/check_credits)                    | A client utility to check your API key's usage, limit, and free tier status on OpenRouter.      |\n| [Get Generation](./examples/get_generation)                  | Fetches detailed post-generation statistics, including cost and native token counts.            |\n\nDetails on specific features and client utility methods are available in the examples linked above. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamwavecut%2Fgopenrouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamwavecut%2Fgopenrouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamwavecut%2Fgopenrouter/lists"}