Skip to main content

Integrations: Chat Models

In LangChainGo every provider implements the same llms.Model interface, so a "chat model" is just a provider used with GenerateContent and chat messages. Construction is provider-specific; the calling code is identical.

Providers

ProviderPackageConstructor
OpenAIllms/openaiopenai.New()
Anthropicllms/anthropicanthropic.New()
Google Geminillms/googleaigoogleai.New(ctx)
Vertex AIllms/googleai/vertexvertex.New(ctx)
AWS Bedrockllms/bedrockbedrock.New()
Mistralllms/mistralmistral.New()
Ollamallms/ollamaollama.New()
Hugging Facellms/huggingfacehuggingface.New()

OpenAI-compatible endpoints (Groq, DeepSeek, OpenRouter, NVIDIA, Ollama Cloud, …) use the llms/openai package with openai.WithBaseURL(...). See the per-provider pages under LLM Integrations for details.

Sending chat messages

import (
"github.com/vxcontrol/langchaingo/llms"
"github.com/vxcontrol/langchaingo/llms/openai"
)

llm, err := openai.New()

messages := []llms.MessageContent{
llms.TextParts(llms.ChatMessageTypeSystem, "You are a helpful assistant."),
llms.TextParts(llms.ChatMessageTypeHuman, "Hello!"),
}

resp, err := llm.GenerateContent(ctx, messages)
fmt.Println(resp.Choices[0].Content)

For detailed configuration options for each provider, see the Configure LLM Providers guide.