openfin-setup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

OpenFinance Setup

OpenFinance 设置

Agents only need one thing to use the OpenFinance backend: a valid API key. Wallet creation and delegation happen out-of-band on openfinance.tech — by the time an agent is involved, the user already has (or needs) a key.
Agent使用OpenFinance后端仅需一个条件:有效的API密钥。 钱包创建与授权需在openfinance.tech平台外完成——当Agent介入时,用户已拥有(或需要获取)密钥。

Step 1 — Locate the API key

步骤1 — 查找API密钥

Check, in order:
  1. Env var
    OPENFINANCE_API_KEY
    (preferred).
  2. Any project-level config the agent already has loaded (
    .env
    , secrets manager, MCP config, etc.).
  3. The current conversation — the user may have pasted it.
A valid key looks like
open_
followed by an opaque token.
按以下顺序检查:
  1. 环境变量
    OPENFINANCE_API_KEY
    (优先选择)。
  2. Agent已加载的任何项目级配置(
    .env
    、密钥管理器、MCP配置等)。
  3. 当前对话记录——用户可能已粘贴密钥。
有效的密钥格式为
open_
开头,后跟一串不透明的令牌。

Step 2 — If no key, ask

步骤2 — 若无密钥,询问用户

If none of the above turns up a key, ask the user once:
I need an OpenFinance API key (
open_…
) to call the backend. If you already have one, paste it here. If not, generate one at openfinance.tech and paste it back.
Do not invent, guess, or proceed without one. Do not echo the key back in chat once received — store it for the session and use it in headers.
若以上途径均未找到密钥,仅询问用户一次
我需要一个OpenFinance API密钥(格式为
open_…
)才能调用后端服务。如果您已拥有密钥,请在此处粘贴;如果没有,请前往openfinance.tech生成并粘贴回来。
请勿自行编造、猜测密钥,或在无密钥的情况下继续操作。收到密钥后,请勿在聊天中回显——请在会话中存储密钥,并在请求头中使用。

Step 3 — Verify

步骤3 — 验证密钥

One call confirms the key works and the wallets are provisioned:
http
GET /agent/wallets
x-api-key: open_…
Expected:
json
{ "ethereum": "0x…", "solana": "…" }
  • Either field may be
    null
    if that chain isn't provisioned for the user on openfinance.tech. Read-only and same-chain EVM flows still work; only Solana-origin Relay executes need the Solana wallet.
  • 401 Invalid API key
    → key is wrong or malformed; ask again or send the user back to openfinance.tech.
  • 412 Server is not authorized for this user
    → the user signed up but hasn't completed setup on openfinance.tech. Send them there.
通过一次调用即可确认密钥有效且钱包已配置:
http
GET /agent/wallets
x-api-key: open_…
预期返回:
json
{ "ethereum": "0x…", "solana": "…" }
  • 若用户未在openfinance.tech平台配置对应链,则任一字段可能为
    null
    。只读操作和同链EVM流程仍可正常运行;仅Solana源的Relay执行需要Solana钱包。
  • 返回
    401 Invalid API key
    → 密钥错误或格式不正确;请再次询问用户,或引导其前往openfinance.tech重新获取。
  • 返回
    412 Server is not authorized for this user
    → 用户已注册但未在openfinance.tech完成设置;请引导其前往该平台完成设置。

Auth header on every call

每次调用均需携带认证头

All
/agent/*
routes (except public Polymarket reads) take:
http
x-api-key: open_…
Authorization: Bearer open_…
also works if the framework prefers Bearer.
所有/agent/*路由(公开的Polymarket读取接口除外)均需携带:
http
x-api-key: open_…
若框架偏好Bearer认证,
Authorization: Bearer open_…
同样有效。

Common failures

常见故障排查

SymptomCauseFix
401 Invalid API key
Key not sent, malformed, or revokedConfirm
open_
prefix; reissue at openfinance.tech
412 Server is not authorized for this user
User signed up but didn't finish setupSend user to openfinance.tech to complete setup
400 User has no Solana wallet provisioned
Solana wallet not enabled for the userUser enables Solana wallet on openfinance.tech
症状原因解决方法
401 Invalid API key
未发送密钥、密钥格式错误或已被撤销确认密钥以
open_
开头;前往openfinance.tech重新生成
412 Server is not authorized for this user
用户已注册但未完成设置引导用户前往openfinance.tech完成设置
400 User has no Solana wallet provisioned
用户未启用Solana钱包用户需在openfinance.tech平台启用Solana钱包

What NOT to do

禁止操作

  • Don't ship the raw API key into LLM context or logs. Pass it through headers only.
  • Don't regenerate the key per call. It's long-lived — cache for the session.
  • Don't try to onboard the user yourself (wallet delegation, Privy flows, etc.). That happens on openfinance.tech, not via the agent.
  • 请勿将原始API密钥传入LLM上下文或日志中。仅通过请求头传递。
  • 请勿每次调用都重新生成密钥。密钥为长期有效——请在会话中缓存。
  • 请勿尝试自行引导用户完成注册流程(钱包授权、Privy流程等)。这些操作需在openfinance.tech平台完成,而非通过Agent。