Crate cogito_openai

Crate cogito_openai 

Source
Expand description

An implementation of a client for the OpenAI API.

This provider implements various traits from cogito to provide a uniform way to access the OpenAI API. This makes it easy to swap out other providers for OpenAI in your application, or vice versa.

This library assumes you pass authentication tokens for the OpenAI API using cogito::service::Auth. This means that you are solely responsible for paying the costs of API access; the Cogito developers are not responsible for costs you incur while using this library.

§Cost

There’s no such thing as a free lunch, and there’s no such thing as free OpenAI access, even if OpenAI is a “non-profit” that is building its technology for the betterment of humanity (and not Sam Altman’s bank account). When you create an OpenAI API client, you will need to select an OpenAIModel. Models are billed on a per-token basis, where a token is the smallest unit of text that the model reads and processes. There are three types of tokens: input tokens, cached input tokens, and output tokens.

  • Input tokens are the token used in any requests made to the OpenAPI AI. This is the “prompt” that users of this library send to OpenAI for summarization.
  • Cached input tokens are input tokens that have been reused by GPT. Input tokens are reused by prompts that have a common prefix, as described here.
  • Output tokens are tokens generated in the output that is sent back to a client in response to a request.

Prices are expressed in US dollars per $1 million tokens. As of 17 July 2025, the prices for each model are as follows.

For the latest pricing, see OpenAI’s pricing docs.

ModelDesignationInputCached InputOutput
Gpt5gpt-5$1.25$0.125$10.00
Gpt5minigpt-5-mini$0.25$0.025$2.00
Gpt5nanogpt-5-nano$0.05$0.005$0.40
Gpt4_1nanogpt-4.1-nano$0.10$0.025$0.40
Gpt4ominigpt-4o-mini$0.15$0.075$0.60
Gpt4_1minigpt-4.1-mini$0.40$0.10$1.60
O4minio4-mini$1.10$0.275$4.40
O3minio3-mini$1.10$0.55$4.40
Gpt4_1gpt-4.1$2.00$0.50$8.00
O3o3$2.00$0.50$8.00
Gpt4ogpt-4o$2.50$1.25$10.00
ChatGpt4ochatgpt-4o-latest$5.00-$15.00
O1o1$15.00$7.50$60.00
O3proo3-pro$20.00-$80.00
01proo1-pro$150.00-$600.00

Modules§

client
OpenAI API client.
prelude
Convenience module for splat imports.

Enums§

OpenAIModel
Available OpenAI GPT models.