Ads for Credits All clients Docs FAQ

Using Ads for Credits with LangChain

Last updated 2026-08-31

LangChain's OpenAI chat model class takes the same two arguments as the SDK it wraps. Everything built on top of that class — chains, agents, tools — keeps working unchanged.

The three values

Every client needs the same three. Sign in and take them from the console.

  • Base URL — https://onomeo.com/v1
  • API key — the key shown in your console, starting ac-
  • Model — one of the names on the models page

Step by step

  1. Import the OpenAI chat model class as usual.
  2. Pass the base URL argument set to ours. Its name differs between versions, so use whichever one your version documents.
  3. Pass your key in the API key argument.
  4. Set the model name to one from the models page.

Agents multiply the token cost

A LangChain agent may call the model many times to answer one question, each call carrying the full conversation so far. The credit cost of one agent run is not comparable to one chat message.

Retrieval chains send the retrieved documents on every call. A large context window makes that convenient and expensive at the same time.

Checking it worked

Invoke the model directly with a one-line prompt before wiring it into a chain. If that returns and shows up in the console, the connection is fine and anything after that is a chain problem, not a connection problem.

If it does not connect

A 401 usually means the key was copied with a trailing space. A 404 means the base URL has /v1 twice or not at all — try it the other way. A 400 saying the model is not allowed means the tool sent its own default name instead of one of ours. The full table is on the clients page.


在 LangChain 中使用

最后更新 2026-08-31

LangChain 的 OpenAI 对话模型类接受与其底层 SDK 相同的两个参数。基于该类构建的一切——链、智能体、工具——均无需改动即可继续使用。

需要填的三个值

所有客户端要的都是这三个。登录后在控制台获取。

  • 接口地址 — https://onomeo.com/v1
  • 密钥 — 控制台中显示的密钥,以 ac- 开头
  • 模型名称 — 模型页面所列名称之一

操作步骤

  1. 照常导入 OpenAI 对话模型类。
  2. 传入接口地址参数,设为本站地址。该参数名称在不同版本间有差异,请以您所用版本的文档为准。
  3. 在 API 密钥参数中传入您的密钥。
  4. 将模型名称设为模型页面上列出的名称之一。

智能体会成倍消耗额度

LangChain 智能体回答一个问题可能调用模型多次,且每次调用都会携带当前完整对话。一次智能体运行的额度消耗与一条普通对话不可同日而语。

检索链在每次调用时都会发送检索到的文档。较大的上下文窗口在带来便利的同时也带来了成本。

如何确认配置成功

在接入链之前,先用一行提示词直接调用模型。若能正常返回并出现在控制台中,说明连接无误;之后出现的问题属于链本身,而非连接。

连接失败时

返回 401 通常是密钥复制时末尾带了空格;返回 404 是接口地址中 /v1 重复或缺失,改成另一种写法即可;返回 400 且提示模型不被允许,说明客户端发送的是它自带的默认模型名,需手动填写本站的名称。完整对照表见客户端总览。