A tiny, dependency-light client that gives Anthropic, OpenAI, Gemini, and Moonshot one consistent request and response shape.
from polygate import chat response = chat( provider="anthropic", # or "openai", "gemini", "moonshot" model="claude-sonnet-4-6", messages=[{"role": "user", "content": "Say hi in one word."}],) print(response.content) # "Hi!"print(response.usage) # Usage(prompt_tokens=..., ...)Every adapter translates the same message list into whatever shape the provider actually expects. API keys come from the argument or fall back to the environment.
"anthropic""claude"ANTHROPIC_API_KEY
"openai""gpt"OPENAI_API_KEY
"gemini""google"GEMINI_API_KEY
"moonshot""kimi"MOONSHOT_API_KEY
Adding a provider is one adapter file and one registry line. Contribute one
No more learning four response formats. Anything a provider returns that polygate does not normalize is still there, untouched, under raw.
Extra keyword arguments pass straight through to the provider, so provider-specific options like tools, top_p, or stop sequences keep working without polygate needing to know about them.
polygate is not trying to out-feature LiteLLM, Portkey, or Helicone. It is the smallest layer that normalizes requests and responses across providers, with each adapter readable in under 100 lines. Retries, caching, and routing are yours to build on top, with whatever opinions your project actually needs.