You are here: Building with agents › The kits › Models.OpenAi
Summary#
Osysharp.Models.OpenAi is the class that talks to OpenAI's Chat Completions API — and to any endpoint that speaks the same wire: a gateway of your own, a model you host yourself.
Point BaseUrl at another host and the same class serves it. The host is your choice, so your app grants it by name on the use line; that grant is the only authority.
| Package | Osysharp.Models.OpenAi, version 1.0.0 |
| You add it with | use Osysharp.Models.OpenAi; in the app's manifest. |
| It sits on | [[agent-kit-llm|Llm]] |
| It also uses | Http — parts of the platform's own library |
| Its own test app | A recipe box that reads recipes people paste in — kits/openai/tests |
Description#
What do you get without writing anything?#
- Complete and stream, with tools.
- Token counts reported to the meter.
When do you need it?#
When your models are OpenAI's, or are served by something OpenAI-compatible.
What does it expose?#
The tables below are generated from the kit itself, not written by hand: osy kits Osysharp.Models.OpenAi --surface lists each of
them with the code of the kit's own test app that uses it, and the tests that show it working.
Types you use
| Type | What it is |
|---|---|
OpenAiClient | The OpenAI Chat Completions API as an ILlmClient. |
OpenAiChatRequest | What goes UP. |
OpenAiStreamOptions | include_usage is what makes a stream meterable. |
OpenAiChatResponse | What comes back from a non-streaming call. |
OpenAiChoice | One choice. |
OpenAiToolCall | One tool call. |
OpenAiToolCallFunction | arguments is json TEXT, not a document — OpenAI's own shape, and the opposite of Anthropic's input. |
OpenAiUsage | The token counts. |
OpenAiStreamChunk | One chunk of a streamed answer. |
What to read next#
- Osysharp.Llm — every call to a model: which one, what it may cost, what it did cost — every call to a model: which one, what it may cost, what it did cost
- Osysharp.Models.Gemini — Google's Gemini models as a provider — Google's Gemini models as a provider
- The map of the kits — which sits on which, and what each one is for — the map of the kits — which sits on which, and what each one is for
Go deeper#
- [[agent-llm-calls#providers]] — how a provider is written and named
- [[agent-llm-calls#models]] — saying which models the app has