LangChain with a custom base URL

Create ChatOpenAI with this base_url and your key, and LangChain runs Claude, GPT and Grok models through your AIGROW key, in chains and agents alike.

Already have a code? Redeem it on API access, then create a key.

Python, with langchain-openai

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="claude-opus-5.5",
    base_url="https://aigrow.gg/v1",
    api_key="ag_your_key_here",
    use_responses_api=False,
)

print(llm.invoke("Reply with the word ready").content)

Swap ag_your_key_here for a key from API access.

Where the setting lives

Python, every model
pip install -U langchain-openai
Python, Claude on ChatAnthropic
pip install -U langchain-anthropic
JavaScript
npm install @langchain/openai @langchain/anthropic @langchain/core

Claude on ChatAnthropic

ChatAnthropic adds /v1/messages itself, so base_url is https://aigrow.gg with nothing after it. Set max_tokens to the length you want; for an id LangChain does not know, it falls back to a default of its own.

from langchain_anthropic import ChatAnthropic

llm = ChatAnthropic(
    model="claude-opus-5.5",
    base_url="https://aigrow.gg",
    api_key="ag_your_key_here",
    max_tokens=1024,
)

In JavaScript

The same two models in LangChain.js: configuration.baseURL on ChatOpenAI, anthropicApiUrl on ChatAnthropic.

import { ChatOpenAI } from '@langchain/openai';
import { ChatAnthropic } from '@langchain/anthropic';

const gpt = new ChatOpenAI({
  model: 'gpt-6-astra',
  apiKey: 'ag_your_key_here',
  configuration: { baseURL: 'https://aigrow.gg/v1' },
});

const claude = new ChatAnthropic({
  model: 'claude-opus-5.5',
  apiKey: 'ag_your_key_here',
  anthropicApiUrl: 'https://aigrow.gg',
});

Or with environment variables

ChatOpenAI reads OPENAI_API_BASE, then OPENAI_BASE_URL. ChatAnthropic reads ANTHROPIC_API_URL, then ANTHROPIC_BASE_URL. A base_url in the code wins over all of them.

export OPENAI_API_BASE=https://aigrow.gg/v1
export OPENAI_API_KEY=ag_your_key_here
export ANTHROPIC_BASE_URL=https://aigrow.gg
export ANTHROPIC_API_KEY=ag_your_key_here

Which model to use

Put the id in exactly as it is written here.

Claude Opus 5.5claude-opus-5.5
The default in every block on this page, and the cheapest Claude model here per token sent and received. Context: 1,000,000 tokens.
Grok 4.7grok-4.7
The lowest output price here. Its context is half the size of the Claude models. Context: 500,000 tokens.
GPT-6 Astragpt-6-astra
For a GPT model. It costs as much per token as Fable, more than Opus. Context: 1,050,000 tokens.
Claude Fable 5.1claude-fable-5.1
Costs more per token than Opus. Compare the two on the coding leaderboard before you switch. Context: 1,000,000 tokens.

The price list has every id and its credit rate, Claude API pricing has the list prices, and the coding leaderboard compares the models on coding prompts.

Check that it works

First the key on its own, then LangChain with it.

The key

Ask for the model list. It needs a valid key and costs nothing.

curl https://aigrow.gg/v1/models -H "Authorization: Bearer ag_your_key_here"

A working key gets the list back:

{
  "object": "list",
  "data": [
    { "id": "claude-opus-5.5", "object": "model", ... },
    { "id": "claude-fable-5.1", "object": "model", ... },
    { "id": "gpt-6-astra", "object": "model", ... },
    { "id": "claude-sonnet-5.5", "object": "model", ... },
    { "id": "gpt-6.1-sol", "object": "model", ... },
    { "id": "grok-4.7", "object": "model", ... },
    ...
  ],
  "has_more": false
}

LangChain

Save the block as check.py, put your key in and run it.

python check.py

A working setup prints the reply:

ready

When it fails

The LangChain errors first, then the answers the endpoint gives any tool.

404 once tools or reasoning are added
ChatOpenAI moved the call to the Responses API, which it does on its own for built-in tools, reasoning settings and some GPT models. use_responses_api=False, as in the block, keeps every call on chat completions.
404 on ChatAnthropic
base_url ends in /v1. ChatAnthropic adds /v1/messages itself, so it is https://aigrow.gg.
The key is sent to OpenAI or Anthropic
The base URL did not reach the model. Pass base_url to ChatOpenAI or ChatAnthropic directly; it wins over every environment variable.
My tool says 401 or authentication error
The key is missing or mistyped. Copy it again from API access on the dashboard, and make sure it is sent as the key, not as a model name. A revoked key fails the same way: create a new one and swap it in.
I get 402 or a message about credit
Your balance is empty. Open API access on the dashboard, redeem a code or buy another pack, and the next request goes through. Nothing else needs to change.
It says 404 or Unknown model
The model has to be one the endpoint serves, for example claude-opus-5.5. The provider’s own spellings work too (claude-opus-5-5, anthropic/claude-opus-5.5), but a dated id or any model outside the catalogue is rejected before the request is forwarded, and nothing is billed. Request GET /v1/models with your key for the live list, or read the ids on the price list.
Requests are rejected with 429
The endpoint’s capacity is shared by every buyer: about 20 requests a minute and 4 at once. Each 429 carries a retry-after header, and the OpenAI and Anthropic SDKs wait that long and retry on their own. In a loop of your own, wait the seconds it names or lower your concurrency.
The model is unavailable right now
A 404 that says the model is not available right now means it is briefly down at the upstream provider, not a problem with your key or balance. Retry in a moment or send the request to another model.
I get a 502 or 503
A transient upstream or configuration hiccup, not a charge against your balance. Retry the request; if it keeps failing, reach us through the store and we will look into it.

What does not work through AIGROW

  • OpenAI built-in tools such as web search, file search and code interpreter, which ChatOpenAI sends to the Responses API. Tools you bind with bind_tools run in your own code and work.

  • Live web search inside the model. A web search tool sent with a request is answered from what the model already knows, with no live results. A tool that fetches pages on your own machine still works.

  • Any endpoint past these three: /v1/messages, /v1/chat/completions and /v1/models. The Responses API, embeddings and token counting answer 404.

  • Router fields such as models, route, provider and plugins. They are dropped, so a request always goes to the one model it names.

What a month of LangChain costs

LangChain is billed per token at the credit rates in the price list. An agent sends the whole conversation again with each step, so a long task costs more than its last message suggests; the activity log on API access shows what each request cost.

Questions about LangChain and a custom API

How do I set base_url in LangChain ChatOpenAI?
Pass base_url="https://aigrow.gg/v1" and api_key with your key when you create ChatOpenAI. openai_api_base is another name for the same setting, and OPENAI_API_BASE or OPENAI_BASE_URL in the environment work too.
How do I set a base URL for ChatAnthropic?
Pass base_url="https://aigrow.gg" in Python, or anthropicApiUrl in JavaScript. Leave /v1 off, because the client adds /v1/messages itself. ANTHROPIC_BASE_URL in the environment works too.
Why set use_responses_api=False?
ChatOpenAI switches to the Responses API on its own for built-in tools, reasoning settings and some GPT models, and the endpoint serves chat completions only. False keeps every call there.
Can ChatOpenAI run Claude models?
Yes. The endpoint serves Claude models on the OpenAI protocol too, so model="claude-opus-5.5" works in ChatOpenAI with the same base_url. ChatAnthropic is the way to send them on the Anthropic protocol.

Sources: LangChain ChatOpenAI · LangChain ChatAnthropic reference · LangChain ChatOpenAI for JavaScript. Read 21 October 2026.

Set up another tool

  • Claude CodeAnthropic protocol

    Four environment variables, in the shell or in settings.json.

  • ClineOpenAI protocol

    The OpenAI Compatible provider, four fields in the settings screen.

  • Roo CodeOpenAI protocol

    The OpenAI Compatible provider, the same fields as Cline.

  • Kilo CodeOpenAI protocol

    A custom provider in the Providers tab; the model list fills itself.

  • ContinueOpenAI protocol

    A models entry in config.yaml, with provider openai and an apiBase.

  • AiderOpenAI protocol

    OPENAI_API_BASE and OPENAI_API_KEY, then openai/ before the model id.

  • OpenCodeOpenAI protocol

    A provider block in opencode.json and the key through /connect.

  • ZedAnthropic and OpenAI protocols

    An Anthropic compatible provider for Claude, an OpenAI compatible one for GPT and Grok.

  • GooseOpenAI protocol

    The OpenAI provider with OPENAI_HOST, or a custom provider file.

  • Vercel AI SDKAnthropic and OpenAI protocols

    The OpenAI Compatible provider for every model, or the Anthropic provider for Claude.

  • OpenAI Agents SDKOpenAI protocol

    Your own AsyncOpenAI client, switched to chat completions, with tracing off.

The API guide has the SDKs, curl, the endpoints and the rate limits.

Paste the block and LangChain runs on your credit.

Buy a credit pack, redeem the code from your email on API access, create a key and put it in place of ag_your_key_here.