Osy#betaRun it on Osyrin: osyrin.com

Reference / Agent

Osysharp.Models.OpenAi — OpenAI's models, and anything that speaks the same wire, as a provider

`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.

previewagentsguidekit

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.

PackageOsysharp.Models.OpenAi, version 1.0.0
You add it withuse Osysharp.Models.OpenAi; in the app's manifest.
It sits on[[agent-kit-llm|Llm]]
It also usesHttp — parts of the platform's own library
Its own test appA 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

TypeWhat it is
OpenAiClientThe OpenAI Chat Completions API as an ILlmClient.
OpenAiChatRequestWhat goes UP.
OpenAiStreamOptionsinclude_usage is what makes a stream meterable.
OpenAiChatResponseWhat comes back from a non-streaming call.
OpenAiChoiceOne choice.
OpenAiToolCallOne tool call.
OpenAiToolCallFunctionarguments is json TEXT, not a document — OpenAI's own shape, and the opposite of Anthropic's input.
OpenAiUsageThe token counts.
OpenAiStreamChunkOne chunk of a streamed answer.

Go deeper#

  • [[agent-llm-calls#providers]] — how a provider is written and named
  • [[agent-llm-calls#models]] — saying which models the app has

Related

The map of the kits — which sits on which, and what each one is for

The agents family is 29 kits. Two are under everything: `Osysharp.Llm` for every model call and `Osysharp.Agents` for…

The Llm kit — call a model, and know what each call cost

`Osysharp.Llm` is the road every model call takes, written in Osy#: the operator's AI switch, the app's router, a…

The Llm kit — call a model, and know what each call cost

`Osysharp.Llm` is the road every model call takes, written in Osy#: the operator's AI switch, the app's router, a…