Skip to main content

LangChain Adapter

Every AI workflow needs a model call somewhere, and nobody wants to wire a different vendor SDK for each provider — or lose governance the moment a prompt leaves the building. The LangChain adapter gives the venue one governed LLM surface: OpenAI, Anthropic, Ollama, and xAI, plus any OpenAI-compatible endpoint, behind a consistent interface for messages, tool calling, and structured output. Swap providers without touching the calling code; every call is a job in the audit trail.

This adapter powers the Level 3 (LLM call) layer in the agent architecture. It can also be invoked directly for one-shot LLM calls. Covia is model-agnostic; the default models below are what a backend uses when you don't set model, not a recommendation.

Backends​

OperationProviderDefault ModelAPI Key Secret
langchain:openaiOpenAIgpt-5.6-terraOPENAI_API_KEY
langchain:anthropicAnthropicclaude-sonnet-5ANTHROPIC_API_KEY
langchain:geminiGoogle Geminigemini-3.6-flashGOOGLE_API_KEY
langchain:xaixAI (Grok)grok-4.3XAI_API_KEY
langchain:deepseekDeepSeekdeepseek-v4-flashDEEPSEEK_API_KEY
langchain:mistralMistralmistral-medium-latestMISTRAL_API_KEY
langchain:openrouterOpenRouteropenrouter/autoOPENROUTER_API_KEY
langchain:ollamaOllama (local)qwenNone required

Any other OpenAI-compatible provider or local gateway works through langchain:openai by setting the url field. langchain:models reports what this venue actually offers — providers, models, recommendations by intent, and each operation’s declared model facet.

Setting API Keys​

Store API keys via the secrets manager:

{ "operation": "v/ops/secret/set", "input": { "name": "OPENAI_API_KEY", "value": "sk-..." } }
{ "operation": "v/ops/secret/set", "input": { "name": "ANTHROPIC_API_KEY", "value": "sk-ant-..." } }

Keys are resolved from the caller's secret store at invocation time. A backend that requires a key but can't resolve one fails fast with an error naming the secret it expected — it does not silently continue.

Usage​

Simple Prompt​

{
"operation": "v/ops/langchain/openai",
"input": {
"prompt": "What is the capital of France?",
"model": "gpt-5.4-mini"
}
}

Response: { "response": "The capital of France is Paris." }

Messages with System Prompt​

{
"operation": "v/ops/langchain/anthropic",
"input": {
"model": "claude-sonnet-5",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Explain lattice technology in one paragraph." }
]
}
}

Response:

{
"role": "assistant",
"content": "Lattice technology is a mathematical framework..."
}

Tool Calling​

Provide tool definitions and the LLM can request tool calls:

{
"operation": "v/ops/langchain/openai",
"input": {
"model": "gpt-5.4-mini",
"messages": [
{ "role": "user", "content": "What's the weather in London?" }
],
"tools": [
{
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": { "type": "string" }
},
"required": ["city"]
}
}
]
}
}

Response:

{
"role": "assistant",
"toolCalls": [
{ "id": "call_abc123", "name": "get_weather", "arguments": { "city": "London" } }
]
}

To continue the conversation, execute the tool and send the result back:

{
"messages": [
{ "role": "user", "content": "What's the weather in London?" },
{ "role": "assistant", "toolCalls": [{ "id": "call_abc123", "name": "get_weather", "arguments": { "city": "London" } }] },
{ "role": "tool", "id": "call_abc123", "name": "get_weather", "content": "{\"temp\": 15, \"condition\": \"cloudy\"}" }
],
"tools": [...]
}

Structured Output​

Request JSON output conforming to a schema:

{
"operation": "v/ops/langchain/openai",
"input": {
"model": "gpt-5.4-mini",
"messages": [
{ "role": "user", "content": "Extract the person's name and age from: 'Alice is 30 years old'" }
],
"responseFormat": {
"name": "PersonInfo",
"schema": {
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "integer" }
},
"required": ["name", "age"],
"additionalProperties": false
}
}
}
}

The OpenAI backend enables strict mode by default — the response is guaranteed to conform to the schema.

Input Reference​

ParameterTypeDefaultDescription
promptstring—Simple prompt (alternative to messages)
systemPromptstring—System message (with prompt mode)
messagesarray—Conversation messages (system, user, assistant, tool)
toolsarray—Tool definitions for function calling
modelstringBackend defaultModel name override
responseFormatstring or object"text""text", "json", or {name, schema}
apiKeystringFrom secret storeOverride API key
urlstringBackend defaultOverride API endpoint (use for OpenAI-compatible providers)

Assistant responses also carry tokens ({input, output, total}) and finishReason when the provider reports them.