Skip to main content
The ai package provides core AI functionality including generation, models, tools, and prompts.

Generate Options

WithModelName()

Specifies the model by name.

WithModel()

Specifies the model instance.

WithPrompt()

Sets the user prompt.

WithSystem()

Sets system instructions.

WithMessages()

Provides conversation history.

WithTools()

Enables tools for the model.

WithToolChoice()

Controls tool usage.

WithConfig()

Sets generation parameters.

WithOutputType()

Sets structured output schema from type.

WithOutputSchema()

Sets output JSON schema.

WithDocs()

Provides context documents.

WithStreaming()

Enables streaming with callback.

Types

Message

Roles:
  • ai.RoleUser
  • ai.RoleModel
  • ai.RoleSystem
  • ai.RoleTool

Part

ModelResponse

ModelRequest

GenerationCommonConfig