azureopenai

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an Azure OpenAI LLM client.

Azure OpenAI provides OpenAI models through Microsoft Azure. The API is similar to OpenAI's but uses different authentication (api-key header instead of Bearer token) and requires deployment names instead of model names.

func New

func New(config Config) (*Client, error)

New creates a new Azure OpenAI client

func (*Client) Chat

func (c *Client) Chat(ctx context.Context, messages []core.Message, opts ...core.Option) (*core.Response, error)

Chat performs a non-streaming chat completion

func (*Client) ChatStream

func (c *Client) ChatStream(ctx context.Context, messages []core.Message, opts ...core.Option) (*core.Stream, error)

ChatStream performs a streaming chat completion

type Config

type Config struct {
	base.Config
	Endpoint   string // Azure OpenAI endpoint (e.g., https://your-resource.openai.azure.com)
	APIVersion string // API version (e.g., 2024-03-01-preview)
}

Config defines configuration for the Azure OpenAI client.

Azure OpenAI requires additional configuration beyond the standard OpenAI client: - Endpoint: Your Azure OpenAI resource endpoint - APIVersion: The API version to use (e.g., "2024-03-01-preview") - Model: Your deployment name (not the model name)

Example:

config := azureopenai.Config{
    Config: base.Config{
        APIKey: "your-azure-key",
        Model:  "my-gpt4-deployment", // deployment name, not "gpt-4"
    },
    Endpoint:   "https://your-resource.openai.azure.com",
    APIVersion: "2024-03-01-preview",
}
client, err := azureopenai.New(config)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL