Expand description
Cogito: Helping you produce AI slop with large language models since 2025.
Cogito provides a uniform interface to AI service providers such as
OpenAI and Anthropic Claude, including an abstract representation of
an AiModel, an AIClient( providing a high-level interface to an
AI service, an AIRequest to represent common features of AI services,
and a Service to represent connectivity over HTTP (or other protocols)
or allow testing code to easily mock an AI service. These building blocks
make it easy for you to implement individual clients for specific AI
service providers. You can then build your application using these
provider implementations, making it easy to switch out providers in your
application without changing more than few use statements.
§Design
The heart and soul of Cogito (if an artificial intelligence module can be
said to have either a heart or a soul) is AIClient. AIClient exposes
a single method, send(), which sends an AIRequest to an AI
service’s API (probably by using an underlying HTTP Service instance).
If AIClient is the heart and soul of Cogito, AIRequest is the meat
and bones. AIRequest instances represent the generalized features of
an AI service, such as model specification, system prompts, and of
course input. Each AI provider defines its own AIRequest type,
making it easy to implement specific functionality behind a uniform
interface. Similarly, each AI provider can implement AIResponse to
handle responses from its associated API, returning data in a uniform way.
Finally, Service can be used to provide different low-level ways of
communicating with the AI service’s API. Often times this will consist
of an HTTP service that talks to a live API, as well as a test API
service that can be used for mocking API calls during tests.
All of these traits, of course, are generally implemented by individual provider crates, such as cogito-openai, so you rarely need to work with these data types directly, unless you are implementing a client for an AI service.
Modules§
- client
- Interfaces for AI provider API client implementations.
- prelude
- Convenience module for the most common Cogito imports.
- service
- Services for communicating with AI service providers over HTTP.
Traits§
- AiModel
- Represents an AI model.