Skip to main content
This is the hello-world of ai_sdk. You only need two imports: the provider factory and the generate_text helper.
1

Install dependencies

Make sure the environment variable OPENAI_API_KEY is set.
2

Create a model instance & generate text

Expected output (your wording may vary):

What just happened?

  1. openai() returns a LanguageModel wrapper that talks to the OpenAI Chat Completions API.
  2. generate_text() sends the prompt, waits for the response, and returns a typed GenerateTextResult.
That’s it – no async boilerplate, no JSON parsing, no provider-locked SDK calls.