# MonkeyAI documentation MonkeyAI provides model access through https://monkeytheme.com. OpenAI-compatible base: https://monkeytheme.com/v1. Anthropic base: https://monkeytheme.com. Access, model capabilities and billing depend on the API key’s group. - [Live pricing (login required)](https://monkeytheme.com/custom/billing-pricing) - [API key management (login required)](https://monkeytheme.com/keys) - [Bilingual documentation sitemap](https://monkeytheme.com/sitemap-docs.xml) ## Guides Source: https://monkeytheme.com/docs # MonkeyAI 接入指南 ## 开始前:账户、密钥与费用 在 [MonkeyAI 注册](https://monkeytheme.com/register)后[登录](https://monkeytheme.com/login),进入[密钥管理](https://monkeytheme.com/keys)创建对应分组的密钥。密钥不是所有模型的通行证:模型必须属于该密钥选择的组,组还可能限制客户端。费用与倍率以[实时价格](https://monkeytheme.com/custom/billing-pricing)为准,本指南不固定报价。 ## 选择接入方式 | 任务 | 教程 | 先确认什么 | | --- | --- | --- | | 准备命令行环境 | [Node.js](/docs/nodejs) | Windows、macOS 或 Linux 的 node/npm | | 在项目中使用 Codex | [Codex](/docs/codex) | Responses 协议与分组权限 | | 使用 Claude Code | [Claude Code](/docs/claude) | Anthropic 根地址与模型 | | 使用 Gemini CLI | [Gemini CLI](/docs/gemini) | Gemini 原生协议与认证模式 | | 在图形界面添加模型 | [TRAE SOLO](/docs/trae-solo) | 自定义提供商支持的协议 | | 配置独立代理 | [OpenClaw](/docs/openclaw)、[Hermes](/docs/hermes) | 必须使用可外接分组 | | 集成到自己的程序 | [API 脚本](/docs/api-scripts) | 协议、返回格式和错误处理 | | 生成或编辑图片 | [图片生成](/docs/image-gen) | 图片模型及对应分组 | | 结构化判断 | [TypeSafe](/docs/typesafe) | 当前可用入口 jev-latest | ## 地址与分组规则 OpenAI 兼容 base 为 `https://monkeytheme.com/v1`;Anthropic base 为 `https://monkeytheme.com`,由客户端补 `/v1/messages`;Gemini 原生路由使用 `/v1beta/`。不要混用协议,也不要重复附加版本路径。 `Codex Pro(仅限Codex)` 仅允许 ChatGPT 桌面版和 Codex CLI,禁止外接 OpenClaw、Hermes、脚本及生图。`Codex Pro(外接版)` 支持外接和图片模型;`Codex Lite(特价福利)` 支持外接,但没有免费 Fast 档位,当前也未列出图片模型。`Claude Max(仅限CC)` 仅允许 Claude Code 与 Claude Desktop;外接用途选择 `Claude Max(外接版)`、`Claude Plus(精品)` 或适当的官方直连组。 ## 完成一次可控验证 先检查客户端版本、地址、模型拼写与密钥组,再在自己的终端发起一次简短请求;该操作可能计费。能启动客户端不等于 API 接通。示例需在你自己的环境中配置密钥后运行。保留脱敏错误码和请求 ID,勿分享 Authorization 头、配置中的密钥或完整日志。 ## 平台与能力边界 Windows 使用 PowerShell;需要 Unix 工具的客户端可使用 WSL。macOS 使用终端,Linux 使用对应发行版的软件管理方式。请按各页的官方安装与自定义提供商步骤操作。模型广场列出模型不代表客户端已支持所有工具、缓存、图片或视频参数;本站没有 Muse/Hunyuan 分组,不承诺这两类能力。 Source: https://monkeytheme.com/docs/nodejs # 安装 Node.js 与 npm ## 准备与版本选择 Node.js 是多个 CLI 的运行环境,npm 用于安装客户端。先到 [Node.js 官方下载](https://nodejs.org/en/download)选择满足目标客户端要求的 LTS;不要把旧终端中已有的版本当成最新要求。安装环境本身不需要 MonkeyAI 密钥。 OpenClaw 需要 Node 24.x 至少 24.16 或 26.1+,安全版本建议 24.22.1+ / 26.12.1+。请在官方页面选择满足要求的版本;发行版仓库或默认 Homebrew 包不保证满足此要求。 ## Windows 下载匹配 x64/ARM64 架构的官方安装包,按安装器提示保留 PATH 与 npm 组件,完成后重新打开 PowerShell。已安装 Chocolatey 或 Scoop 的用户,也可选择其中一种方式,不要混装多个来源: ```powershell choco install nodejs-lts # 或在已配置的 Scoop 中运行: scoop install nodejs-lts ``` 这些是第三方包管理器命令,不是本站安装脚本。受管理的电脑应使用组织允许的软件源。 ## macOS 可使用官方 macOS 安装包。已有 Homebrew 时,可运行 `brew install node`;该公式不保证固定为 LTS,请核对安装版本和客户端要求。Apple Silicon 与 Intel 应选对应架构。安装后重开终端,让 PATH 生效。 ## Linux Ubuntu / Debian 可先查询发行版版本,再安装: ```bash apt-cache policy nodejs sudo apt-get install nodejs npm ``` RHEL 系发行版先检查可用的软件流或仓库,再按系统版本安装: ```bash dnf info nodejs sudo dnf install nodejs npm ``` 旧版 CentOS 的仓库可能已经停止维护;若仓库版本不满足要求,使用 Node.js 官方下载页提供的匹配架构发行包及其安装说明。不要为了凑版本直接执行未知远程脚本。npm 全局安装发生权限错误时,优先使用用户拥有的 Node 安装位置,而非对所有命令追加 sudo。 ## 验证与排错 ```text node --version npm --version ``` 两条命令都应输出版本。Windows 用 `where.exe node`,macOS / Linux 用 `command -v node` 检查实际路径。若找不到命令,重开终端并检查 PATH;若版本不一致,清理旧安装路径。PowerShell 阻止 npm.ps1 时,可在确认来源后使用 `npm.cmd`,不必全局降低执行策略。 ## 下一步 选择 [Codex](/docs/codex)、[Claude Code](/docs/claude) 或 [Gemini CLI](/docs/gemini)。客户端安装成功后还需要单独设置 MonkeyAI 地址、密钥组和模型。 Source: https://monkeytheme.com/docs/codex # 手动连接 Codex 到 MonkeyAI ## 选择密钥与模型 从[密钥管理](https://monkeytheme.com/keys)取得密钥。当前模型列表确认 `gpt-6.1-sol` 可用于 Codex Pro 两类组、Codex Lite 与 GPT 官方直连组。`Codex Pro(仅限Codex)` 只允许 ChatGPT 桌面版和 Codex CLI,不能复用于脚本、Hermes、OpenClaw 或生图。需要外接时选择 `Codex Pro(外接版)`;Lite 支持外接但没有免费 Fast。价格见[实时价格](https://monkeytheme.com/custom/billing-pricing)。 ## Windows、macOS、Linux 安装 先完成 [Node.js](/docs/nodejs)。在 Windows PowerShell、macOS 或 Linux 终端手动执行: Windows 若当前版本原生支持不完整,可在 WSL 内安装和配置;WSL 的主目录与 Windows 用户目录不同。Linux 遇权限错误时使用用户拥有的 npm 环境。 ### Windows ```powershell npm install -g @openai/codex@latest codex --version ``` ### macOS ```bash npm install -g @openai/codex@latest codex --version ``` ### Linux ```bash npm install -g @openai/codex@latest codex --version ``` ## 配置 Responses 提供商 先备份已有配置,再用文本编辑器合并以下最小配置,不要覆盖原有项目设置。macOS / Linux 文件为 `~/.codex/config.toml`;Windows 为 `%USERPROFILE%\.codex\config.toml`。目录不存在时手动创建。 ```toml model_provider = "monkeyai" model = "gpt-6.1-sol" [model_providers.monkeyai] name = "MonkeyAI" base_url = "https://monkeytheme.com/v1" wire_api = "responses" requires_openai_auth = false env_key = "MONKEYAI_API_KEY" ``` 认证使用环境变量,密钥不写入 TOML。此处为用户级配置。参见 [官方配置参考](https://learn.chatgpt.com/docs/config-file/config-reference)。在启动 Codex 的同一终端私下输入密钥;以下输入不会回显,也不会将密钥字面值写入命令历史。关闭终端后需重新设置。 ### Windows ```powershell $env:MONKEYAI_API_KEY = [System.Net.NetworkCredential]::new("", (Read-Host "MonkeyAI API key" -AsSecureString)).Password ``` ### macOS ```bash read -r -s "MONKEYAI_API_KEY?MonkeyAI API key: " export MONKEYAI_API_KEY ``` ### Linux ```bash read -r -s -p "MonkeyAI API key: " MONKEYAI_API_KEY export MONKEYAI_API_KEY ``` ## 启动与桌面端 进入要处理的项目目录运行 `codex`。先检查所选提供商和模型,阅读工具执行审批再继续。改配置后退出并重开已有会话。桌面客户端是否读取同一份配置取决于版本与运行环境;不要仅因 CLI 生效就认为桌面端已接通,需分别检查模型与错误信息。 ## 验证与恢复 用户可在确认费用后询问一个简短问题验证。401 先查占位符和密钥;403 查组与客户端限制;model_not_found 查模型 ID;404 查是否误用 Chat Completions 或重复 `/v1`。失败时恢复备份,收集脱敏错误,不公开配置密钥。 Source: https://monkeytheme.com/docs/claude # Claude Code 手动配置 ## 密钥与分组 在[密钥管理](https://monkeytheme.com/keys)选择 Claude 分组。`Claude Max(仅限CC)` 仅允许 Claude Code 和 Claude Desktop;TRAE、OpenClaw、Hermes 和脚本必须改用 `Claude Max(外接版)`、`Claude Plus(精品)` 或适当的官方直连组。当前 Plus 清单包含 `claude-opus-4-8`,以下用它演示。其他组的模型名称必须逐组核对,尤其 Haiku 的日期后缀不能随意替换。费用见[价格页](https://monkeytheme.com/custom/billing-pricing)。 ## 安装:Windows、macOS、Linux 先准备 [Node.js](/docs/nodejs),在相应终端执行: Windows 还需按客户端版本要求准备 Git for Windows;若原生环境不受支持,可在 WSL 内安装。macOS 和 Linux 在普通用户的 npm 环境运行,遇权限问题先修复安装位置。本页不依赖本站尚未验证的一键脚本,也不会执行远程安装器。 ### Windows ```powershell npm install -g @anthropic-ai/claude-code claude --version ``` ### macOS ```bash npm install -g @anthropic-ai/claude-code claude --version ``` ### Linux ```bash npm install -g @anthropic-ai/claude-code claude --version ``` ## 当前会话的环境变量 Anthropic 使用根地址,不要在 base 后加 `/v1/messages`。Windows PowerShell: ```powershell $env:ANTHROPIC_BASE_URL = "https://monkeytheme.com" $env:ANTHROPIC_AUTH_TOKEN = "YOUR_API_KEY" $env:ANTHROPIC_MODEL = "claude-opus-4-8" $env:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1" claude ``` Windows CMD 可分别使用 `set ANTHROPIC_BASE_URL=https://monkeytheme.com`、`set ANTHROPIC_AUTH_TOKEN=YOUR_API_KEY`、`set ANTHROPIC_MODEL=claude-opus-4-8`、`set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1`,然后运行 `claude`。 macOS / Linux: ```bash export ANTHROPIC_BASE_URL="https://monkeytheme.com" export ANTHROPIC_AUTH_TOKEN="YOUR_API_KEY" export ANTHROPIC_MODEL="claude-opus-4-8" export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1" claude ``` 在项目目录启动。替换占位符时不要把真实密钥放进共享终端记录。非必要流量开关设为 1;它不代表所有网络活动均被禁用。 ## 保存配置与切换模型 会话设置仅影响当前终端及其子进程。Windows 可在用户环境变量界面设置同名变量;macOS zsh 可编辑 `~/.zshrc`,Linux bash 可编辑 `~/.bashrc`,加入对应 export。含密钥文件应限制读取且不入 Git;也可每次私下输入密钥而不永久保存。保存后新开终端。更换组后重新核对模型,重启 Claude Code,避免继承其他提供商的旧认证变量。 ## 验证与排错 启动成功只证明程序可运行。确认地址与模型后,自行发送一次短请求可能计费;请求会按实际用量计费。401 检查 token,403 检查组限制,404 检查根地址,model_not_found 检查准确名称。若仍出现官方登录流程,检查认证方式是否被旧配置覆盖。不要提交真实密钥或完整会话日志。下一步可查看 [Gemini CLI](/docs/gemini) 或 [TRAE SOLO](/docs/trae-solo)。 Source: https://monkeytheme.com/docs/gemini # Gemini CLI 手动配置 ## 选择分组与协议 在[密钥管理](https://monkeytheme.com/keys)创建 Gemini 密钥。当前 `Gemini (特价渠道)` 和 `Gemini (官方直连)` 均列出 `gemini-3.8-flash`。特价渠道描述明确提示缓存命中几乎没有,不应依赖缓存节省成本。官方直连组的模型集并非完全相同。费用以[实时价格](https://monkeytheme.com/custom/billing-pricing)为准。 Gemini CLI 使用 Gemini 原生 API;本站已有 `/v1beta/` 路由。不要把 OpenAI 的 `/v1` base 套到原生客户端。 ## Windows、macOS、Linux 安装 完成 [Node.js](/docs/nodejs),在 Windows PowerShell、macOS / Linux 终端执行: macOS 已使用 Homebrew 时,也可选择 `brew install gemini-cli`,两种方式选其一。Windows 若版本要求 WSL,就在 WSL 内配置;Linux 使用用户拥有的 npm 安装位置,不默认添加 sudo。 ### Windows ```powershell npm install -g @google/gemini-cli gemini --version ``` ### macOS ```bash npm install -g @google/gemini-cli gemini --version ``` ### Linux ```bash npm install -g @google/gemini-cli gemini --version ``` ## 当前会话配置 当前 Gemini CLI 支持 `GOOGLE_GEMINI_BASE_URL`、`GEMINI_API_KEY` 与 `GEMINI_MODEL`。自定义 base 使用网关 / 自定义地址的 API key 认证;旧版本界面可能称为 API key 模式,也可能不支持自定义 base。Windows PowerShell: ```powershell $env:GOOGLE_GEMINI_BASE_URL = "https://monkeytheme.com" $env:GEMINI_API_KEY = "YOUR_API_KEY" $env:GEMINI_MODEL = "gemini-3.8-flash" gemini ``` macOS / Linux: ```bash export GOOGLE_GEMINI_BASE_URL="https://monkeytheme.com" export GEMINI_API_KEY="YOUR_API_KEY" export GEMINI_MODEL="gemini-3.8-flash" gemini ``` Windows CMD 对应使用 `set NAME=value`。启动时若出现认证选择,选择 API key 方式;Google 账户 OAuth 或 Vertex 项目认证不应被当作本站密钥认证。若版本不识别变量或仍连接官方服务,暂停请求并查该版本帮助,不猜测替代 JSON 字段,也不要把密钥填进网址。 ## 持久化与日常使用 Windows 可在用户环境变量界面保存同名变量;macOS zsh 编辑 `~/.zshrc`,Linux bash 编辑 `~/.bashrc` 添加 export。保护含密钥文件,勿提交到 Git,重开终端后再启动。仅临时试用时无需永久保存。在项目目录运行 `gemini`;非交互示例为: ```text gemini -p "用一句话解释这个项目的用途" ``` 先确认将发送的文件和提示词适合交给服务处理。 ## 验证与排错 用户运行后可能计费。401 检查密钥和认证模式;404 检查是否重复添加 `/v1beta` 或错用 `/v1`;model_not_found 检查组中是否存在该 ID。环境变量修改后要重启客户端。成功安装、成功登录 Google 账户与成功通过 MonkeyAI 调用是三件不同的事。其他接入方式见 [TRAE SOLO](/docs/trae-solo)。 Source: https://monkeytheme.com/docs/trae-solo # 在 TRAE SOLO 添加 MonkeyAI 模型 ## 准备客户端和密钥 Windows 与 macOS 用户使用 [TRAE 官方网站](https://www.trae.ai/)提供的、适配自己系统的客户端。Linux 是否存在官方 SOLO 发行版需在官方下载页核对;不能保证 Linux 桌面可用,可改用 [Codex CLI](/docs/codex) 或 [Claude Code](/docs/claude)。不要从非官方镜像安装软件。 在[密钥管理](https://monkeytheme.com/keys)为 TRAE 创建可外接组密钥。不要使用 `Codex Pro(仅限Codex)` 或 `Claude Max(仅限CC)`,TRAE 不在这两个组的允许客户端中。费用见[价格页](https://monkeytheme.com/custom/billing-pricing)。 ## 打开自定义模型入口 打开设置,进入“模型”,选择“添加模型”,再进入“自定义配置”。界面名称可能随版本调整。先记录应用版本;若界面没有自定义接口功能,不要用官方账户登录字段代替。已有模型先保留,便于失败后切回。 ## 按协议填写 | 项目 | OpenAI / Codex 路线 | Claude / Anthropic 路线 | | --- | --- | --- | | 自定义名称 | MonkeyAI Codex | MonkeyAI Claude | | 接口 base | https://monkeytheme.com/v1 | https://monkeytheme.com | | 模型 ID 示例 | gpt-6.1-sol | claude-opus-4-8 | | 组示例 | Codex Pro(外接版) | Claude Plus(精品) | | 密钥 | YOUR_API_KEY | YOUR_API_KEY | 提供商应与接口协议一致。Codex 路线要求该版本支持 Responses;仅有 Chat Completions 的表单不能证明 Codex Responses 兼容。如果只有完整请求 URL 字段,先查该版本说明确认路径拼接方式,不盲目添加后缀。Claude 使用 Anthropic Messages,base 不手动带 `/v1/messages`。将自己的密钥私下输入密码字段,不写进模型显示名称。 ## 保存并检查 保存后在会话中显式选择新模型,观察界面显示的模型 ID。用户可在确认费用后发送一个短提示词;请求会按实际用量计费。模型出现在下拉框不代表已经接通。 ## 常见问题与恢复 401 检查密钥是否完整;403 检查是否误选仅限官方客户端的组;model_not_found 检查组与模型;404 或协议错误检查 Responses / Messages 支持及 base 拼接。若自定义提供商不支持所需协议,使用对应 CLI,不改写未经确认的配置文件。删除失败的自定义项或切回已有项即可恢复。截图排错前遮盖密钥、账户和私人会话。 Source: https://monkeytheme.com/docs/openclaw # OpenClaw 手动接入 MonkeyAI ## 选择可外接通道 在[密钥管理](https://monkeytheme.com/keys)创建专用密钥。Claude 可选 `Claude Plus(精品)`、`Claude Max(外接版)` 或合适的官方直连组;Codex 可选 `Codex Pro(外接版)` 或支持外接的 Lite。`Claude Max(仅限CC)` 和 `Codex Pro(仅限Codex)` 都不能用于 OpenClaw。Lite 没有免费 Fast 档位。查看[价格](https://monkeytheme.com/custom/billing-pricing)后再发请求。 | 通道 | base | 模型示例 | 协议要求 | | --- | --- | --- | --- | | Claude | https://monkeytheme.com | claude-opus-4-8 | Anthropic Messages | | Codex | https://monkeytheme.com/v1 | gpt-6.1-sol | OpenAI Responses | 以上模型已出现在当前模型列表的对应组中,但不代表所有 OpenClaw 版本均已完成兼容测试。 ## 安装 先准备 [Node.js](/docs/nodejs)。官方要求 Node 24.x 至少 24.16,或 26.1+;安全版本建议 24.22.1+ 或 26.12.1+。使用 npm 12 或 11.16+ 执行以下命令;较旧 npm 需省略 `--allow-scripts=openclaw`。详见 [官方安装说明](https://docs.openclaw.ai/install)。Windows 原生与 WSL 均受支持,WSL 为可选方式。 ### Windows ```powershell npm install -g openclaw@latest --allow-scripts=openclaw openclaw --version openclaw onboard ``` ### macOS ```bash npm install -g openclaw@latest --allow-scripts=openclaw openclaw --version openclaw onboard ``` ### Linux ```bash npm install -g openclaw@latest --allow-scripts=openclaw openclaw --version openclaw onboard ``` ## 手动交互配置 先备份现有设置。运行 `openclaw onboard`,选择 Custom setup → More… / Custom Provider,明确选择自定义接入,不复用已有官方 OAuth。按上表输入 base、密钥、兼容协议与模型。Claude 选择 Anthropic Messages;Codex 仅在当前版本提供 Responses 时选择该协议,只有 Chat Completions 时不能靠更换模型名实现兼容。向导保存前会进行真实模型验证,可能按用量计费。详见 [官方向导](https://docs.openclaw.ai/start/wizard)。文本模型可见不代表工具调用兼容。 ## 启动与权限 完成后按该版本提示启动;可先查看 `openclaw --help` 确认。检查默认模型和提供商是否为新配置。先用空白工作目录验证,再按需要授予文件、工具与消息渠道权限,不要为了验证接入就开放全部能力。 ## 检查、排错与恢复 用户自行发起简短请求可能计费。401 查密钥,403 查外接组,404 查协议与 base,model_not_found 查模型 ID。保留脱敏错误和版本号;不要读取或分享真实密钥配置。失败时用客户端支持的方式恢复先前提供商或备份。其他代理接入见 [Hermes](/docs/hermes)。 Source: https://monkeytheme.com/docs/hermes # 使用交互向导配置 Hermes Agent ## 接入条件与分组 Hermes 是独立代理,必须使用可外接的 MonkeyAI 密钥。在[密钥管理](https://monkeytheme.com/keys)选择 `Claude Plus(精品)`、`Claude Max(外接版)` 或适当的官方直连组;使用 GPT 时可选择 `Codex Pro(外接版)` 或支持外接的 Lite。不要使用 `Claude Max(仅限CC)` 或 `Codex Pro(仅限Codex)`。Lite 没有免费 Fast,也未列出图片模型。费用见[实时价格](https://monkeytheme.com/custom/billing-pricing)。 ## 安装 [官方安装说明](https://hermes-agent.nousresearch.com/docs/getting-started/installation)支持 Windows 原生、macOS(含 Apple Silicon)与 Linux;WSL 可选。下载官方脚本,先阅读确认,再执行。安装后重开终端,运行 `hermes --help`。 ### Windows ```powershell Invoke-WebRequest https://hermes-agent.nousresearch.com/install.ps1 -OutFile hermes-install.ps1 Get-Content .\hermes-install.ps1 # 阅读脚本后执行 & .\hermes-install.ps1 ``` ### macOS ```bash curl -fsSL https://hermes-agent.nousresearch.com/install.sh -o hermes-install.sh less hermes-install.sh # 阅读脚本后执行 bash hermes-install.sh ``` ### Linux ```bash curl -fsSL https://hermes-agent.nousresearch.com/install.sh -o hermes-install.sh less hermes-install.sh # 阅读脚本后执行 bash hermes-install.sh ``` ## 运行 hermes model 使用已确认的交互式模型配置入口: ```text hermes model ``` 按向导选择可自定义地址的提供商或自定义 API,逐项输入以下信息。界面文字随版本变化,以当前帮助为准: | 项目 | Claude 路线 | Codex 路线 | | --- | --- | --- | | API 协议 | Anthropic Messages | OpenAI Responses | | base | https://monkeytheme.com | https://monkeytheme.com/v1 | | 模型 ID | claude-opus-4-8 | gpt-6.1-sol | | 密钥 | 私下输入自己的密钥 | 私下输入自己的密钥 | Claude base 不手动附加 `/v1/messages`。Codex 必须确认向导支持 Responses,自定义 OpenAI 选项若仅代表 Chat Completions 则不足以证明兼容。若向导不提供所需协议,暂停该路线,核对版本或选择受支持的 Claude 路线。不要选择依赖官方 OAuth 的入口后填本站密钥。 ## 保存并启动 完成向导后查看其保存结果提示,确认提供商与模型,再运行 `hermes`。若已有会话,先退出重开。Windows、WSL、macOS 与 Linux 应在实际运行 Hermes 的同一用户环境中配置。通过交互向导保存即可,无需手动创建配置文件。 ## 验证与恢复 用户可确认[价格](https://monkeytheme.com/custom/billing-pricing)后在空白目录询问一个短问题。401 查密钥,403 查组与外接限制,404 查协议与地址,model_not_found 查模型拼写。工具调用失败与文本请求失败需分别排查;文本可用不代表所有工具、图片或长期任务兼容。重新运行 `hermes model` 可切换回先前提供商,保留脱敏错误用于排错。图片能力见 [图片生成](/docs/image-gen)。 Source: https://monkeytheme.com/docs/api-scripts # MonkeyAI API 脚本:文本、视觉与图片 ## 准备密钥与运行环境 在 [注册](https://monkeytheme.com/register) 或 [登录](https://monkeytheme.com/login) 后,前往 [密钥管理](https://monkeytheme.com/keys) 创建适合接口的分组密钥。将密钥放在运行脚本的环境变量中;不要写进代码、浏览器或提交记录。运行脚本会产生请求与潜在费用。 Python 3 安装 `python3 -m pip install openai anthropic`;Node.js 使用支持当前 SDK 的 LTS 版本,安装 `npm install openai @anthropic-ai/sdk`。请使用官方 SDK 软件包。 ```bash export MONKEYAI_API_KEY="YOUR_API_KEY" ``` ```powershell $env:MONKEYAI_API_KEY="YOUR_API_KEY" ``` ## 协议与分组选择 | 协议 | 稳定路径 | 本文模型 | | --- | --- | --- | | Responses | `POST /v1/responses` | `gpt-6.1-sol` | | Chat Completions | `POST /v1/chat/completions` | `gpt-6.1-sol` | | Messages | `POST /v1/messages` | `claude-opus-4-8` | OpenAI SDK 的 base 是 `https://monkeytheme.com/v1`;Anthropic SDK 的 base 是 `https://monkeytheme.com`,由 SDK 拼接 `/v1/messages`。不要重复拼接 `/v1`。 模型列表列有上述模型。外接脚本选择 Codex Pro(外接版)、GPT 官方直连或允许外接的 Claude 分组;“仅限Codex”“仅限CC”分组不能按通用脚本使用。模型出现在广场不等于任意密钥都可访问,也不能据此认定所有视觉、工具或协议特性均已验证。Gemini 原生路由为 `/v1beta/`,不能仅靠更换模型名把原生请求改成这三种格式。 ## Python:三种协议的文本、视觉与流式 保存为 `api_demo.py`。三个参数依次选择协议、输入和传输方式,例如 `python3 api_demo.py responses text plain`。把 `text` 改为 `vision` 时,先在当前目录放置自己的静态 `input.png`;把 `plain` 改为 `stream` 使用流式处理。三个协议均有文本和视觉分支。它们展示协议结构,所选分组的视觉兼容性仍需实际验证。 ```python import base64 import os import sys from pathlib import Path from openai import OpenAI, APIError from anthropic import Anthropic, APIError as AnthropicError # python api_demo.py responses|chat|messages text|vision plain|stream protocol, mode, delivery = sys.argv[1:] if protocol not in {"responses", "chat", "messages"}: raise ValueError("Unknown protocol") if mode not in {"text", "vision"} or delivery not in {"plain", "stream"}: raise ValueError("Invalid mode or delivery") streaming = delivery == "stream" key = os.environ["MONKEYAI_API_KEY"] image = None if mode == "vision": image = base64.b64encode(Path("input.png").read_bytes()).decode("ascii") try: if protocol == "messages": client = Anthropic(api_key=key, base_url="https://monkeytheme.com", timeout=120.0, max_retries=0) content = [{"type": "text", "text": "Describe the visible evidence."}] if image: content.append({"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": image}}) args = dict(model="claude-opus-4-8", max_tokens=600, messages=[{"role": "user", "content": content}]) if streaming: with client.messages.stream(**args) as events: for text in events.text_stream: print(text, end="", flush=True) final = events.get_final_message() print("\nusage:", final.usage) else: result = client.messages.create(**args) for block in result.content: if block.type == "text": print(block.text) print("usage:", result.usage) else: client = OpenAI(api_key=key, base_url="https://monkeytheme.com/v1", timeout=120.0, max_retries=0) if protocol == "responses": content = [{"type": "input_text", "text": "Describe the visible evidence."}] if image: content.append({"type": "input_image", "image_url": "data:image/png;base64," + image}) result = client.responses.create(model="gpt-6.1-sol", input=[{"role": "user", "content": content}], stream=streaming) if streaming: with result as events: for event in events: if event.type == "response.output_text.delta": print(event.delta, end="", flush=True) elif event.type in {"error", "response.failed", "response.incomplete"}: raise RuntimeError(str(event)) elif event.type == "response.completed": print("\nusage:", event.response.usage) else: print(result.output_text) print("usage:", result.usage) else: content = [{"type": "text", "text": "Describe the visible evidence."}] if image: content.append({"type": "image_url", "image_url": { "url": "data:image/png;base64," + image}}) result = client.chat.completions.create(model="gpt-6.1-sol", messages=[{"role": "user", "content": content}], stream=streaming) if streaming: with result as chunks: for chunk in chunks: if chunk.choices: print(chunk.choices[0].delta.content or "", end="", flush=True) else: print(result.choices[0].message.content) print("usage:", result.usage) except (APIError, AnthropicError, OSError, RuntimeError) as error: print("Request failed:", error, file=sys.stderr) sys.exit(1) ``` ## Node.js:同样的六类输入与两种传输 保存为 `api_demo.mjs`,运行方式如 `node api_demo.mjs messages vision stream`。不要将 SSE 当成一个完整 JSON 文档解析。SDK 负责事件边界,应用只拼接文本增量。 ```javascript import fs from "node:fs/promises"; import OpenAI from "openai"; import Anthropic from "@anthropic-ai/sdk"; // node api_demo.mjs responses|chat|messages text|vision plain|stream try { const [protocol, mode, delivery] = process.argv.slice(2); if (!["responses", "chat", "messages"].includes(protocol) || !["text", "vision"].includes(mode) || !["plain", "stream"].includes(delivery)) { throw new Error("Invalid protocol, mode or delivery"); } const apiKey = process.env.MONKEYAI_API_KEY; if (!apiKey) throw new Error("Set MONKEYAI_API_KEY"); const stream = delivery === "stream"; const image = mode === "vision" ? (await fs.readFile("input.png")).toString("base64") : null; if (protocol === "messages") { const client = new Anthropic({apiKey, baseURL: "https://monkeytheme.com", timeout: 120000, maxRetries: 0}); const content = [{type: "text", text: "Describe the visible evidence."}]; if (image) content.push({type: "image", source: { type: "base64", media_type: "image/png", data: image}}); const args = {model: "claude-opus-4-8", max_tokens: 600, messages: [{role: "user", content}]}; if (stream) { const events = client.messages.stream(args); for await (const event of events) { if (event.type === "content_block_delta" && event.delta.type === "text_delta") process.stdout.write(event.delta.text); } console.log("\nusage:", (await events.finalMessage()).usage); } else { const result = await client.messages.create(args); for (const block of result.content) if (block.type === "text") console.log(block.text); console.log("usage:", result.usage); } } else { const client = new OpenAI({apiKey, baseURL: "https://monkeytheme.com/v1", timeout: 120000, maxRetries: 0}); if (protocol === "responses") { const content = [{type: "input_text", text: "Describe the visible evidence."}]; if (image) content.push({type: "input_image", image_url: `data:image/png;base64,${image}`}); const result = await client.responses.create({model: "gpt-6.1-sol", input: [{role: "user", content}], stream}); if (stream) { for await (const event of result) { if (event.type === "response.output_text.delta") process.stdout.write(event.delta); if (["error", "response.failed", "response.incomplete"].includes(event.type)) throw new Error(JSON.stringify(event)); if (event.type === "response.completed") console.log("\nusage:", event.response.usage); } } else { console.log(result.output_text); console.log("usage:", result.usage); } } else { const content = [{type: "text", text: "Describe the visible evidence."}]; if (image) content.push({type: "image_url", image_url: {url: `data:image/png;base64,${image}`}}); const result = await client.chat.completions.create({model: "gpt-6.1-sol", messages: [{role: "user", content}], stream}); if (stream) { for await (const chunk of result) process.stdout.write(chunk.choices[0]?.delta?.content ?? ""); } else { console.log(result.choices[0].message.content); console.log("usage:", result.usage); } } } } catch (error) { console.error("Request failed:", error.status ?? "", error.message); process.exitCode = 1; } ``` ## 流式完成与用量 Responses 只读取 `response.output_text.delta` 文本;完成事件可提供 usage,失败或不完整事件必须保留为失败状态。Messages 只拼接文本块,结束后读取最终消息。Chat 的首个块或 usage 块可能没有 choices,delta 也可能为空;上例已跳过空值。Chat 流不保证提供 usage;确认分组支持后可请求 `stream_options: {include_usage: true}` 并读取最终 usage 块,否则以后台用量记录对账。 连接中断后的部分文本不能当作完整成功结果。生产程序应记录完成状态、停止原因和可用请求 ID;需要提前停止时关闭流。示例没有调用工具;若启用工具调用,还需累积并校验工具参数,不能把它们当作普通文本。不要对已经生成部分内容的请求盲目重试,重复调用可能重复收费。 ## 图片生成与编辑 模型列表列有 `gpt-image-2`,Codex Pro(外接版)与 ChatGPT 生图分组包含它;Codex Lite 不在该生图列表中。下面分别使用稳定路径 `/v1/images/generations` 和 `/v1/images/edits`,编辑由 SDK 发送 multipart 文件。模型列名不是编辑、遮罩、尺寸或返回格式已在当前渠道验证的证据;这些兼容性待验证。示例要求 Base64 返回,遇到仅 URL 返回会明确报错,不自动下载未知地址。 Python 保存为 `image_demo.py`,Node.js 保存为 `image_demo.mjs`,参数为 `generate` 或 `edit`。编辑需自备 `input.png`。输出会覆盖当前目录的 `output.png`,请先保留已有文件。这里没有视频示例:当前证据不能保证 MonkeyAI 视频生成可用。 ```python import base64 import os import sys from pathlib import Path from openai import OpenAI, APIError # python image_demo.py generate|edit try: client = OpenAI(api_key=os.environ["MONKEYAI_API_KEY"], base_url="https://monkeytheme.com/v1", timeout=180.0, max_retries=0) mode = sys.argv[1] if mode == "generate": result = client.images.generate(model="gpt-image-2", prompt="A paper sculpture of a mountain, plain background", n=1) elif mode == "edit": with open("input.png", "rb") as image: result = client.images.edit(model="gpt-image-2", image=image, prompt="Change the background to pale blue; preserve the subject", n=1) else: raise ValueError("Use generate or edit") if not result.data or not result.data[0].b64_json: raise RuntimeError("No Base64 image returned; inspect the response format safely") Path("output.png").write_bytes(base64.b64decode(result.data[0].b64_json, validate=True)) print("Saved output.png") except (APIError, OSError, ValueError, RuntimeError) as error: print("Image request failed:", error, file=sys.stderr) sys.exit(1) ``` ```javascript import fs from "node:fs"; import OpenAI from "openai"; try { if (!process.env.MONKEYAI_API_KEY) throw new Error("Set MONKEYAI_API_KEY"); const client = new OpenAI({apiKey: process.env.MONKEYAI_API_KEY, baseURL: "https://monkeytheme.com/v1", timeout: 180000, maxRetries: 0}); const mode = process.argv[2]; let result; if (mode === "generate") { result = await client.images.generate({model: "gpt-image-2", prompt: "A paper sculpture of a mountain, plain background", n: 1}); } else if (mode === "edit") { result = await client.images.edit({model: "gpt-image-2", image: fs.createReadStream("input.png"), prompt: "Change the background to pale blue; preserve the subject", n: 1}); } else throw new Error("Use generate or edit"); if (!result.data?.[0]?.b64_json) throw new Error("No Base64 image returned; inspect response format safely"); fs.writeFileSync("output.png", Buffer.from(result.data[0].b64_json, "base64")); console.log("Saved output.png"); } catch (error) { console.error("Image request failed:", error.status ?? "", error.message); process.exitCode = 1; } ``` ## 大文件输入 模型不会自动读取本地路径。先在本地提取 PDF/办公文件中的文字;扫描件需要 OCR。Python 用 `Path("document.txt").read_text(encoding="utf-8")`,Node.js 用 `await fs.readFile("document.txt", "utf8")` 取得正文,再替换示例文本块中的 text。不要把整个二进制文件放进 text。文件上传、file ID、远程 URL 自动抓取与 PDF 原生输入在这些分组上尚未验证,不能假定 `/v1/files` 可用。按段落拆分超长输入,保留段落 ID,再汇总分段结果;图片 Base64 增大会同时影响请求体与输入预算。本站确切文件、图片和上下文限制需按模型/渠道确认。 ## 费用与排错 以 [实时价格](https://monkeytheme.com/custom/billing-pricing) 和账户用量为准。文本输入、输出、缓存及图片的计费方式可能不同,分组倍率和长上下文规则也可能影响费用。不要将每图价格当成文本单价,或把无 usage 的流式响应当成免费。 | 现象 | 处理 | | --- | --- | | 401 / 403 | 检查环境变量、密钥有效性、余额及分组客户端限制;不要打印 Authorization | | 404 / model_not_found | 核对完整模型 ID、协议路径和密钥分组;不要随意追加 `/v1` | | 400 / 422 | 检查协议专用内容块、图片 MIME 类型及可选参数;逐项减少不兼容选项 | | 413 / 上下文超限 | 缩小图片、提取文本、分段;字符数不是 Token 数 | | 429 / 503 | 降低并发,尊重 Retry-After,设置有上限的指数退避 | | 超时 / 中断 | 检查代理与网络,标记部分结果;确认计费状态再决定是否重试 | | 图片输出为空 | 核对生图分组、返回格式和权限;不要伪造图片或成功结果 | 错误可能包含用户输入,记录前应脱敏。示例禁用 SDK 自动重试,避免教程隐式多次请求;HTTP 错误、网络异常及流内错误都需要处理。确切 SDK 版本兼容、实时通道和端到端视觉/编辑效果需按所选渠道确认。 Source: https://monkeytheme.com/docs/image-gen # MonkeyAI 图片生成与编辑指南 ## 先确认模型与分组 在[密钥管理](https://monkeytheme.com/keys)创建图片用途的专用密钥,查看[实时价格](https://monkeytheme.com/custom/billing-pricing)。以下按当前模型列表整理,不把组描述中的能力宣传当作已验证的 API 参数。 | 分组 | 清单内图片模型 | 使用限制 | | --- | --- | --- | | Codex Pro(外接版) | gpt-image-2、gpt-image-2.5-flare、gpt-image-2.5-sunburst | 可外接,具体生成/编辑参数仍需核对 | | ChatGPT 生图分组 | gpt-image-2、gpt-image-2.5-flare、gpt-image-2.5-sunburst | 图片专用分组 | | Gemini (官方直连) | gemini-2.5-flash-image、gemini-3.1-flash-image、gemini-3.1-flash-lite-image、gemini-nano-banana-2.1 | 使用 Gemini 原生协议,核对返回格式 | `Codex Pro(仅限Codex)` 明确禁止生图;Codex Lite 当前没有图片模型。当前 Grok 企业版虽然描述支持图片与视频,但模型列表未列出专用图像 ID;本页不承诺 `grok-imagine-image` 或其 quality 变体可调用。当前 Gemini 清单也未列出 `gemini-3-pro-image`。Muse/Hunyuan 没有本站组,不提供可用性承诺。 ## 手动准备客户端或 skill 不要将真实密钥贴到聊天中。若你已有可信生图客户端或 skill,先检查其来源、支持协议、可自定义 base 的方式与密钥读取规则;没有这些条件时,先使用 [API 脚本教程](/docs/api-scripts)核对接口,而非安装未知脚本。 OpenAI 兼容 base 是 `https://monkeytheme.com/v1`;Gemini 原生路由为 `/v1beta/`,客户端通常以根地址为 base。具体图片生成、编辑端点和参数应按所选模型核对,不能把 Responses、Images 与 Gemini 的字段混在同一个请求中。模型可见不等于生成和编辑均已测试。 ## Windows、macOS、Linux 的密钥准备 如果你的可信工具明确支持 `IMAGE_GEN_API_KEY`,可在其父终端设置占位示例。Windows PowerShell: ```powershell $env:IMAGE_GEN_API_KEY = "YOUR_API_KEY" ``` macOS / Linux: ```bash export IMAGE_GEN_API_KEY="YOUR_API_KEY" ``` 这个变量名仅是工具间约定,不是所有客户端自动识别的标准。按工具说明映射密钥,工具必须从同一终端启动才能继承会话变量。GUI 程序可能不继承 shell 环境,应使用其安全密钥输入方式。不要将真实密钥写进提示词、源码或 Git。 ## 三种任务的明确提示词 文生图: “生成一张蓝白配色的产品海报,主体居中,顶部留标题空位,不添加文字。使用 gpt-image-2,先说明将使用的分组和尺寸。” 参考图生图: “根据我提供的参考图创建新构图,保留主体轮廓和配色,改变背景与视角。先确认所选模型接受图片输入。” 图片编辑: “只把上传图的背景改成浅蓝色,保持主体位置、比例和现有文字。若工具不支持局部编辑,请先说明限制。” 这些提示词是任务表达示例,不会安装 skill,也不保证触发某个接口。切换模型前先核对密钥组。参考图应是用户有权处理的文件;上传前确认客户端会发送哪些文件。 ## 返回结果、排错与验收 按工具实际响应区分图片 URL、base64 或 Gemini 内容块;不要假设固定返回格式。URL 可能过期,保存结果后确认文件能打开,再比较主体、文字和编辑范围。尺寸、张数、透明背景、参考图数量等参数需按所选渠道确认,不承诺任意取值可用。 用户实际运行可能计费。401 检查密钥,403 检查组,model_not_found 检查模型 ID;格式错误先查协议和模型的输入限制。工具缺少图片支持时,不能通过换一个文本模型名解决。报告问题时遮盖密钥,并保留脱敏错误与所用模型。程序化集成见 [API 脚本](/docs/api-scripts)。 Source: https://monkeytheme.com/docs/typesafe # MonkeyAI TypeSafe:结构化判断与评分 ## 入口、密钥与当前版本 TypeSafe 面向规则判断、分类和评分,使用 `POST https://monkeytheme.com/v1/systemone`,返回完整 JSON,不使用聊天消息协议或流式输出。在 [注册](https://monkeytheme.com/register) 或 [登录](https://monkeytheme.com/login) 后,到 [密钥管理](https://monkeytheme.com/keys) 选择 TypeSafe 分组密钥。 **当前后端仅接受 `jev-latest`。** 模型广场虽列出 `jev-1.13.0`、`jev-1.14.0`,目前不承诺固定版本可调用;不要把广场展示当成可调用证据。本文所有请求使用 `jev-latest`,不保证它当前映射到某个固定版本。需要复现时保存请求、时间和实际返回的 model,并先确认版本支持状态。 示例没有发送真实请求,没有虚构返回值。运行会发送你的数据并可能计费。密钥仅从环境读取,不能放入网页前端或 Git。 ```bash export TYPESAFE_API_KEY="YOUR_API_KEY" ``` ```powershell $env:TYPESAFE_API_KEY="YOUR_API_KEY" ``` 使用 Bash/WSL 的最小 cURL 请求(需要已设置环境变量;运行将发送请求): ```bash curl --fail-with-body --connect-timeout 15 --max-time 120 "https://monkeytheme.com/v1/systemone" -H "Authorization: Bearer $TYPESAFE_API_KEY" -H "Content-Type: application/json" --data-binary '{"model":"jev-latest","state":"Please replace my damaged parcel.","questions":{"replacement":{"type":"noul","instructions":"Is a replacement requested?"}}}' ``` ## state、questions 与答案结构 请求包含 `model`、`state` 和非空对象 `questions`。state 可为字符串、对象或数组,保存待评估材料;questions 的键是你定义的结果 ID,每题用 `instructions` 写清要判断什么。返回 `answers` 使用相同 ID。不要发送 `messages`、`prompt` 或 `stream=true`。图片资产使用顶层 `assets`。 | type | criteria | 如何读取 | | --- | --- | --- | | `noul` | 可选的 `true` / `false` 描述对象 | `answers.ID.noul` 为 0–1 概率,不是布尔值;业务自行设置阈值 | | `choice` | 选项 ID 到描述的对象,参考协议为 1–255 项 | `answers.ID.choice` 是选项 ID;同时检查 confidence 与 probabilities | | `score` | 按低到高排列的描述数组,参考协议为 1–10 级,从 0 编号 | `answers.ID.score` 是概率加权分数,可能是小数;参考 legend、confidence、probabilities | | `box` | 用 instructions 描述一个具体目标 | 图片定位实验题型;MonkeyAI 当前可用性未验证,不能当成已支持 | 同一请求内各题独立评估,共享 state;不能要求第二题读取第一题尚未返回的答案。依赖前一步判断的流程应由应用拆成多次调用。confidence 与概率含义不同,0.8 等阈值需要用自己的验证集校准,不能把概率直接当成真假或准确率保证。 ## Python:判断、分类、评分与文件模式 Python 3 只需标准库。保存为 `typesafe_demo.py`,文本示例运行 `python3 typesafe_demo.py text`;文件模式运行 `python3 typesafe_demo.py file`。图片模式为待验证示例,确认渠道能力后再使用。示例实际打印响应,不预设任何成功答案。 ```python import base64 import json import os import sys import urllib.error import urllib.request import uuid from pathlib import Path # python typesafe_demo.py text|file|image def evaluate(body): request = urllib.request.Request( "https://monkeytheme.com/v1/systemone", data=json.dumps(body, ensure_ascii=False).encode("utf-8"), headers={"Authorization": "Bearer " + os.environ["TYPESAFE_API_KEY"], "Content-Type": "application/json"}, method="POST") try: with urllib.request.urlopen(request, timeout=120) as response: result = json.load(response) except urllib.error.HTTPError as error: # Do not log credentials or private request contents. raise RuntimeError(f"HTTP {error.code}; inspect a redacted error body locally") from error if not isinstance(result.get("answers"), dict): raise ValueError("Response has no answers object") return result try: mode = sys.argv[1] body = {"model": "jev-latest", "state": {"note": "The delivery arrived damaged. Can someone arrange a replacement this week?"}, "questions": { "replacement": {"type": "noul", "instructions": "Is a replacement requested?", "criteria": {"true": "A replacement is requested.", "false": "No replacement is requested."}}, "route": {"type": "choice", "instructions": "Select the responsible team.", "criteria": {"delivery": "Damaged or missing deliveries.", "account": "Account access.", "other": "Other issues."}}, "priority": {"type": "score", "instructions": "Assess the stated time pressure.", "criteria": ["No deadline.", "Within a week.", "Immediate action required."]}}} if mode == "file": body["state"] = Path("document.txt").read_text(encoding="utf-8") body["questions"] = {"renewal": {"type": "noul", "instructions": "Does the document require an explicit renewal decision?"}} elif mode == "image": # Unverified on MonkeyAI: confirm image capability before using this mode. ref = str(uuid.uuid4()) body["state"] = {"photo": ref} body["assets"] = {ref: {"type": "image", "format": "png", "data_base64": base64.b64encode(Path("input.png").read_bytes()).decode("ascii")}} body["questions"] = {"label_visible": {"type": "noul", "instructions": "Is a shipping label visible in the image?"}} elif mode != "text": raise ValueError("Use text, file or image") result = evaluate(body) print(json.dumps(result, ensure_ascii=False, indent=2)) if mode == "text": probability = result["answers"]["replacement"]["noul"] if isinstance(probability, bool) or not isinstance(probability, (int, float)) or not 0 <= probability <= 1: raise ValueError("Invalid noul probability") # 0.8 is an illustrative policy threshold, not a service guarantee. print("Review for replacement:", probability >= 0.8) print("usage:", result.get("usage")) except (OSError, ValueError, KeyError, TypeError, RuntimeError) as error: print("TypeSafe request failed:", error, file=sys.stderr) sys.exit(1) ``` ## Node.js:相同任务,无额外依赖 使用支持 fetch 与 AbortSignal.timeout 的 Node.js 18+(建议维护中的 LTS)。保存为 `typesafe_demo.mjs`,运行 `node typesafe_demo.mjs text`、`file` 或确认能力后的 `image`。HTTP 错误、JSON 错误、文件读取错误和超时都会走错误分支;不会自动重试产生额外请求。 ```javascript import fs from "node:fs/promises"; import {randomUUID} from "node:crypto"; // node typesafe_demo.mjs text|file|image async function evaluate(body) { const key = process.env.TYPESAFE_API_KEY; if (!key) throw new Error("Set TYPESAFE_API_KEY"); const response = await fetch("https://monkeytheme.com/v1/systemone", { method: "POST", headers: {Authorization: `Bearer ${key}`, "Content-Type": "application/json"}, body: JSON.stringify(body), signal: AbortSignal.timeout(120000) }); if (!response.ok) throw new Error(`HTTP ${response.status}; inspect a redacted error body locally`); const result = await response.json(); if (!result.answers || typeof result.answers !== "object" || Array.isArray(result.answers)) throw new Error("Response has no answers object"); return result; } try { const mode = process.argv[2]; const body = {model: "jev-latest", state: {note: "The delivery arrived damaged. Can someone arrange a replacement this week?"}, questions: { replacement: {type: "noul", instructions: "Is a replacement requested?", criteria: {true: "A replacement is requested.", false: "No replacement is requested."}}, route: {type: "choice", instructions: "Select the responsible team.", criteria: {delivery: "Damaged or missing deliveries.", account: "Account access.", other: "Other issues."}}, priority: {type: "score", instructions: "Assess the stated time pressure.", criteria: ["No deadline.", "Within a week.", "Immediate action required."]} }}; if (mode === "file") { body.state = await fs.readFile("document.txt", "utf8"); body.questions = {renewal: {type: "noul", instructions: "Does the document require an explicit renewal decision?"}}; } else if (mode === "image") { // Unverified on MonkeyAI: confirm image capability before using this mode. const ref = randomUUID(); body.state = {photo: ref}; body.assets = {[ref]: {type: "image", format: "png", data_base64: (await fs.readFile("input.png")).toString("base64")}}; body.questions = {label_visible: {type: "noul", instructions: "Is a shipping label visible in the image?"}}; } else if (mode !== "text") throw new Error("Use text, file or image"); const result = await evaluate(body); console.log(JSON.stringify(result, null, 2)); if (mode === "text") { const probability = result.answers.replacement.noul; if (typeof probability !== "number" || probability < 0 || probability > 1) throw new Error("Invalid noul probability"); console.log("Review for replacement:", probability >= 0.8); } console.log("usage:", result.usage); } catch (error) { console.error("TypeSafe request failed:", error.message); process.exitCode = 1; } ``` ## 图片输入与 Box:未验证能力 图片模式展示参考协议的 JSON + Base64 结构:为图片创建 UUID,在 assets 中放 `type: image`、`format: png` 和不带 data URL 前缀、不换行的 `data_base64`,再用 state.photo 引用该 UUID。JPEG 要同步修改文件名和 format 为 jpg 或 jpeg。重复引用可能增加展开后的输入;共用图片尽量只在 state 引用一次。图片 URL 和本地路径不能替代文件字节,也不能假定服务自动下载它们。multipart、SDK 自动上传及压缩请求体在本站未验证。 参考资料描述静态 PNG/JPEG、每边 280–1568 像素、单图 16 MiB、请求体 32 MiB;**这些不是已验证的 MonkeyAI 限制或容量承诺**,本站及当前别名实际支持的格式、尺寸和上限仍待确认。先校正方向,必要时缩放或补边;Base64 通常增加约三分之一体积。不要据此承诺动画或视频输入。 Box 同样未验证;不能因广场列出 1.14.0 就认定可调用或可定位。待确认后,题目结构为下方示意片段(不是独立请求,也不应直接加入生产示例): ```json {"target": {"type": "box", "instructions": "Locate the shipping label in the referenced image."}} ``` 参考坐标为归一化的 left/top/right/bottom,原点为左上角。对发送图片宽 W、高 H,像素框为 `(left×W, top×H, right×W, bottom×H)`;取整并限制边界,缩放或裁剪后需换算回原图。没有目标时也可能返回框,宜先用 noul 验证目标存在,再决定是否采纳坐标。confidence 可能为 null,不应解释成 0。多个目标拆成明确的单目标问题。上述说明用于理解协议,不代表当前服务已能返回 Box。 ## 长文件与上下文边界 在当前目录准备 UTF-8 的 `document.txt`,两种语言的 file 模式都会读取内容放入 state,检查文档是否要求明确续约决定。文件名、网址本身不会被读取;PDF、Office 和扫描件须先本地提取文本或 OCR,不要直接把二进制解码成 UTF-8。 参考资料提到整次请求与 state 加单题的 262K Token 上限;需确认 MonkeyAI 当前 `jev-latest` 的上下文上限、入口大小或长上下文计费,不能将参考协议上限视为本站容量保证。输入预算包括 state、问题及图片,字符数不是 Token 数。逐段处理超大文件,给每段稳定 ID,在应用中汇总;注意跨段依赖可能影响判断。不要将某段未提到条款误判为整份文档不存在条款。 ## 用量与计费 读取响应中的 `usage.input_tokens`、`usage.output_tokens`,并到 [实时价格](https://monkeytheme.com/custom/billing-pricing) 与账户用量记录核对。清单中 TypeSafe 采用 Token 计费且输出标价为零;实际有效费率仍取决于当前分组规则。若规则确认为仅输入计费,估算为输入 Token ÷ 1,000,000 × 每百万输入有效价格。不要用四舍五入的显示价精确对账,也不要未经确认宣称图片无附加费或长上下文费率不变。图像会影响输入用量;失败或重试的计费应查记录,不凭空推断。 ## 排错与上线前检查 | 现象 | 检查与处理 | | --- | --- | | 401 / 403 | 环境变量、完整密钥、有效期、余额和 TypeSafe 分组;不要打印密钥 | | 404 / 协议错误 | 固定使用 `/v1/systemone`;Chat、Responses、Messages 都不能代替它 | | model_not_found / 固定版本被拒 | 当前仅使用 `jev-latest`;不保证固定版本可用,不要循环重试同一版本 | | 400 / 422 | 检查非空 questions、state、type、instructions、criteria;不发送 stream;图片还需核对引用与编码 | | 413 | 减小文件或图片,考虑 Base64 膨胀及网关限制,拆分请求 | | max_tokens_exceeded | 同时缩减 state、问题与图片,避免重复引用;确认实际上下文上限 | | 429 / 503 | 降低并发,按 Retry-After(如有)做有上限退避;持续失败时保留脱敏请求 ID 给支持人员 | | 超时 / 非 JSON / answers 缺失 | 标记失败,保留脱敏状态与内容类型;核查网关响应,不构造假的答案 | 使用前请确认别名映射、响应字段、图片和 Box 能力、输入限制、运行时兼容性与实际计费;文本请求成功不代表所有能力均可用。 Source: https://monkeytheme.com/en/docs # Connect clients to MonkeyAI ## Before you start: account, key and cost [Register](https://monkeytheme.com/register), [sign in](https://monkeytheme.com/login), then create a key in [key management](https://monkeytheme.com/keys). Choose its group deliberately: a model must belong to that group, and some groups also restrict the client. Check [live pricing](https://monkeytheme.com/custom/billing-pricing) before use; this guide does not freeze prices or multipliers. ## Choose a connection path | Goal | Guide | Check first | | --- | --- | --- | | Prepare a terminal | [Node.js](/en/docs/nodejs) | node/npm on Windows, macOS or Linux | | Work in a project with Codex | [Codex](/en/docs/codex) | Responses protocol and group access | | Use Claude Code | [Claude Code](/en/docs/claude) | Anthropic root URL and model | | Use Gemini CLI | [Gemini CLI](/en/docs/gemini) | Native Gemini protocol and authentication | | Add a model in a GUI | [TRAE SOLO](/en/docs/trae-solo) | Custom provider protocol support | | Configure an independent agent | [OpenClaw](/en/docs/openclaw), [Hermes](/en/docs/hermes) | An external-use group is required | | Integrate your own program | [API scripts](/en/docs/api-scripts) | Protocol, response format and errors | | Generate or edit images | [Image generation](/en/docs/image-gen) | Image model and eligible group | | Make structured judgments | [TypeSafe](/en/docs/typesafe) | Currently usable entry: jev-latest | ## Endpoint and group rules The OpenAI-compatible base is `https://monkeytheme.com/v1`. The Anthropic base is `https://monkeytheme.com`; the client appends `/v1/messages`. Native Gemini routes use `/v1beta/`. Match the protocol and avoid duplicated version paths. `Codex Pro(仅限Codex)` permits only ChatGPT Desktop and Codex CLI: no OpenClaw, Hermes, external scripts or image generation. `Codex Pro(外接版)` permits external clients and lists image models. `Codex Lite(特价福利)` permits external use but has no free Fast tier and currently lists no image models. `Claude Max(仅限CC)` permits only Claude Code and Claude Desktop. For external clients, choose `Claude Max(外接版)`, `Claude Plus(精品)` or a suitable official direct group. ## Perform a controlled verification Check the client version, URL, exact model ID and key group first. A short request from your terminal can then verify access and may incur charges. Launching a client alone does not prove connectivity. No example here has been validated by live inference. Keep a redacted error code and request ID; do not share authorization headers, keys or complete private logs. ## Platforms and capability limits Use PowerShell on Windows, or WSL when a client requires Unix tools; use Terminal on macOS and your distribution's package manager on Linux. Follow each guide’s official installation and custom-provider setup steps. A model listing does not prove support for every tool, cache, image or video parameter. MonkeyAI has no Muse/Hunyuan groups; this documentation does not promise those capabilities. Source: https://monkeytheme.com/en/docs/nodejs # Install Node.js and npm ## Preparation and version selection Node.js runs several clients, while npm installs their packages. Choose an LTS release from [Node.js downloads](https://nodejs.org/en/download) that satisfies your client's version requirement. An existing installation may be too old. Installing this runtime does not require a MonkeyAI key. OpenClaw requires Node 24.x at least 24.16 or 26.1+, with security guidance recommending 24.22.1+ / 26.12.1+. Select a qualifying version from the official download page; distribution repositories and the default Homebrew package may not satisfy this requirement. ## Windows Download the official installer for your x64 or ARM64 system. Keep the npm and PATH components enabled, finish installation and reopen PowerShell. If you already use Chocolatey or Scoop, choose one existing package manager instead of mixing installation sources: ```powershell choco install nodejs-lts # Alternatively, with Scoop already configured: scoop install nodejs-lts ``` These are third-party package manager commands, not MonkeyAI installers. On a managed computer, use your organization's approved source. ## macOS Use the official macOS installer, or run `brew install node` if Homebrew is already installed. The Homebrew formula does not guarantee a pinned LTS version; compare its result with the client's requirements. Match Apple Silicon or Intel architecture and reopen Terminal afterward. ## Linux On Ubuntu / Debian, inspect the distribution's candidate version before installing: ```bash apt-cache policy nodejs sudo apt-get install nodejs npm ``` On RHEL-family systems, inspect the available repository or module stream appropriate to the OS release: ```bash dnf info nodejs sudo dnf install nodejs npm ``` Old CentOS repositories may be unsupported. If packages are too old, use the matching architecture release and instructions from the Node.js download page. Avoid unknown remote installer scripts. For npm global permission errors, prefer a user-owned Node installation over adding sudo to every command. ## Verification and troubleshooting ```text node --version npm --version ``` Both commands should print versions. Locate the executable using `where.exe node` on Windows or `command -v node` on macOS / Linux. Reopen the terminal and inspect PATH when commands are missing; remove obsolete installation paths when versions disagree. If PowerShell blocks npm.ps1, the verified `npm.cmd` executable is an alternative without weakening the global execution policy. ## Next step Continue to [Codex](/en/docs/codex), [Claude Code](/en/docs/claude) or [Gemini CLI](/en/docs/gemini). Each client still needs its MonkeyAI endpoint, eligible key group and model after installation. Source: https://monkeytheme.com/en/docs/codex # Manually connect Codex to MonkeyAI ## Choose a key and model Get a key from [key management](https://monkeytheme.com/keys). The current model listing includes `gpt-6.1-sol` in both Codex Pro groups, Codex Lite and GPT 官方直连. `Codex Pro(仅限Codex)` permits only ChatGPT Desktop and Codex CLI, excluding scripts, Hermes, OpenClaw and image generation. Choose `Codex Pro(外接版)` for external use. Lite permits external use but has no free Fast tier. Consult [live pricing](https://monkeytheme.com/custom/billing-pricing). ## Install on Windows, macOS or Linux Prepare [Node.js](/en/docs/nodejs), then run in Windows PowerShell, macOS Terminal or a Linux shell: If your Windows client release has incomplete native support, install and configure inside WSL; its home directory differs from the Windows user directory. On Linux, resolve global npm permissions with a user-owned runtime. ### Windows ```powershell npm install -g @openai/codex@latest codex --version ``` ### macOS ```bash npm install -g @openai/codex@latest codex --version ``` ### Linux ```bash npm install -g @openai/codex@latest codex --version ``` ## Configure the Responses provider Back up existing configuration and merge this minimal example with a text editor. Do not overwrite project settings. Use `~/.codex/config.toml` on macOS / Linux or `%USERPROFILE%\.codex\config.toml` on Windows; create the directory if needed. ```toml model_provider = "monkeyai" model = "gpt-6.1-sol" [model_providers.monkeyai] name = "MonkeyAI" base_url = "https://monkeytheme.com/v1" wire_api = "responses" requires_openai_auth = false env_key = "MONKEYAI_API_KEY" ``` Authentication uses an environment variable, keeping the key out of TOML. This is user-level configuration. See the [official configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference). Enter the key privately in the terminal that launches Codex. These prompts hide input and keep the literal key out of command history. Set it again after closing the terminal. ### Windows ```powershell $env:MONKEYAI_API_KEY = [System.Net.NetworkCredential]::new("", (Read-Host "MonkeyAI API key" -AsSecureString)).Password ``` ### macOS ```bash read -r -s "MONKEYAI_API_KEY?MonkeyAI API key: " export MONKEYAI_API_KEY ``` ### Linux ```bash read -r -s -p "MonkeyAI API key: " MONKEYAI_API_KEY export MONKEYAI_API_KEY ``` ## Launch and desktop use Run `codex` inside your project. Check the active provider and model, and review tool approval requests. Restart existing sessions after configuration changes. Desktop configuration sharing depends on the application version and environment; validate its selected model and errors separately even when the CLI works. ## Verify and recover After checking cost, you can send a short question. For 401, inspect the placeholder and key; for 403, check group and client restrictions; for model_not_found, check the exact ID; for 404, check Responses support and duplicated `/v1`. Restore the backup if necessary and collect redacted errors without exposing the key. Source: https://monkeytheme.com/en/docs/claude # Configure Claude Code manually ## Key and group selection Choose a Claude group in [key management](https://monkeytheme.com/keys). `Claude Max(仅限CC)` permits only Claude Code and Claude Desktop. TRAE, OpenClaw, Hermes and scripts require `Claude Max(外接版)`, `Claude Plus(精品)` or a suitable official direct group. The current Plus listing includes `claude-opus-4-8`, used below. Check IDs separately for other groups, including dated Haiku variants. See [live pricing](https://monkeytheme.com/custom/billing-pricing). ## Install on Windows, macOS and Linux Prepare [Node.js](/en/docs/nodejs), then run in your terminal: On Windows, provide Git for Windows when required by your client release. Use WSL if the native environment is unsupported. On macOS and Linux, use a normal user's npm installation and fix its location if permissions fail. ### Windows ```powershell npm install -g @anthropic-ai/claude-code claude --version ``` ### macOS ```bash npm install -g @anthropic-ai/claude-code claude --version ``` ### Linux ```bash npm install -g @anthropic-ai/claude-code claude --version ``` ## Set variables for the current session Anthropic uses the root base URL: do not append `/v1/messages` to the base. Windows PowerShell: ```powershell $env:ANTHROPIC_BASE_URL = "https://monkeytheme.com" $env:ANTHROPIC_AUTH_TOKEN = "YOUR_API_KEY" $env:ANTHROPIC_MODEL = "claude-opus-4-8" $env:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1" claude ``` In Windows CMD, use `set ANTHROPIC_BASE_URL=https://monkeytheme.com`, `set ANTHROPIC_AUTH_TOKEN=YOUR_API_KEY`, `set ANTHROPIC_MODEL=claude-opus-4-8` and `set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1`, then run `claude`. macOS / Linux: ```bash export ANTHROPIC_BASE_URL="https://monkeytheme.com" export ANTHROPIC_AUTH_TOKEN="YOUR_API_KEY" export ANTHROPIC_MODEL="claude-opus-4-8" export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1" claude ``` Launch inside the intended project. Replace the placeholder privately and avoid shared terminal history. Keep the nonessential-traffic switch at 1; it does not disable all networking. ## Persist settings and switch models Session variables affect only that terminal and its children. On Windows, use the user environment variable editor for the same names. On macOS zsh, edit `~/.zshrc`; on Linux bash, edit `~/.bashrc` with the corresponding exports. Restrict access to files containing keys and keep them out of Git, or enter the key privately each session instead. Open a new terminal afterward. When changing groups, recheck the model and restart Claude Code; remove conflicting authentication variables from earlier providers. ## Verification and troubleshooting Launching proves installation only. After checking the URL and model, a short request can verify access and may cost money. Check the token for 401, group restrictions for 403, root URL for 404, and exact ID for model_not_found. An unexpected official login flow may indicate an older authentication setting overriding yours. Do not share keys or complete session logs. Continue to [Gemini CLI](/en/docs/gemini) or [TRAE SOLO](/en/docs/trae-solo). Source: https://monkeytheme.com/en/docs/gemini # Configure Gemini CLI manually ## Choose a group and protocol Create a Gemini key in [key management](https://monkeytheme.com/keys). Both `Gemini (特价渠道)` and `Gemini (官方直连)` currently list `gemini-3.8-flash`. The discount group's description warns of almost no cache hits; do not budget around cache savings. The two groups have different model sets. Check [live pricing](https://monkeytheme.com/custom/billing-pricing). Gemini CLI uses the native Gemini API. MonkeyAI provides `/v1beta/` routing; the OpenAI `/v1` base is not the native client's base. ## Install on Windows, macOS and Linux Prepare [Node.js](/en/docs/nodejs), then run in Windows PowerShell or a macOS / Linux terminal: If you already use Homebrew on macOS, `brew install gemini-cli` is an alternative; choose one installation source. Use WSL if your Windows release requires it. On Linux, prefer a user-owned npm installation rather than automatically adding sudo. ### Windows ```powershell npm install -g @google/gemini-cli gemini --version ``` ### macOS ```bash npm install -g @google/gemini-cli gemini --version ``` ### Linux ```bash npm install -g @google/gemini-cli gemini --version ``` ## Configure the current session Current Gemini CLI supports `GOOGLE_GEMINI_BASE_URL`, `GEMINI_API_KEY` and `GEMINI_MODEL`. A custom base uses gateway/custom-base API key authentication; older releases may label this API key mode and may lack custom-base support. Windows PowerShell: ```powershell $env:GOOGLE_GEMINI_BASE_URL = "https://monkeytheme.com" $env:GEMINI_API_KEY = "YOUR_API_KEY" $env:GEMINI_MODEL = "gemini-3.8-flash" gemini ``` macOS / Linux: ```bash export GOOGLE_GEMINI_BASE_URL="https://monkeytheme.com" export GEMINI_API_KEY="YOUR_API_KEY" export GEMINI_MODEL="gemini-3.8-flash" gemini ``` Use `set NAME=value` in Windows CMD. If asked to choose authentication, select API key mode. Google account OAuth or Vertex project authentication does not authenticate a MonkeyAI key. If variables are ignored or traffic still targets the official service, stop and inspect that release's help instead of inventing JSON settings or placing the key in a URL. ## Persist settings and use the client Windows users can save the same names in the user environment editor. Edit `~/.zshrc` for macOS zsh or `~/.bashrc` for Linux bash with the exports. Protect files containing keys, keep them out of Git and reopen the terminal. Temporary trials do not require persistence. Run `gemini` inside your project, or use this noninteractive example: ```text gemini -p "Explain the purpose of this project in one sentence" ``` Review which files and prompts are appropriate to send to the service first. ## Verification and troubleshooting Requests are billed according to actual usage. For 401, check the key and authentication mode; for 404, check duplicated `/v1beta` or an incorrect `/v1`; for model_not_found, verify the ID in your group. Restart after changing variables. Installation, Google account login and a successful MonkeyAI request are separate checks. See [TRAE SOLO](/en/docs/trae-solo) for another connection path. Source: https://monkeytheme.com/en/docs/trae-solo # Add MonkeyAI models to TRAE SOLO ## Prepare the client and key On Windows and macOS, use a matching client from the [official TRAE site](https://www.trae.ai/). Linux SOLO availability must be checked on the official download page; Linux desktop support is not guaranteed. Linux users can use [Codex CLI](/en/docs/codex) or [Claude Code](/en/docs/claude) instead. Avoid unofficial installer mirrors. Create an external-use key in [key management](https://monkeytheme.com/keys). Neither `Codex Pro(仅限Codex)` nor `Claude Max(仅限CC)` permits TRAE. See [live pricing](https://monkeytheme.com/custom/billing-pricing). ## Open custom model settings Open Settings, then Models, Add Model and Custom Configuration. Labels may differ by release. Record the application version. If custom endpoints are absent, official account sign-in fields are not a substitute. Keep an existing working model available for recovery. ## Fill in the matching protocol | Field | OpenAI / Codex path | Claude / Anthropic path | | --- | --- | --- | | Display name | MonkeyAI Codex | MonkeyAI Claude | | API base | https://monkeytheme.com/v1 | https://monkeytheme.com | | Example model ID | gpt-6.1-sol | claude-opus-4-8 | | Example group | Codex Pro(外接版) | Claude Plus(精品) | | Key | YOUR_API_KEY | YOUR_API_KEY | Match the provider to its protocol. The Codex path requires Responses support in your release; a Chat Completions-only form does not establish that compatibility. If the form asks for a full request URL, check how that version constructs paths before adding suffixes. Claude uses Anthropic Messages; do not append `/v1/messages` to its base. Enter your own key privately in the secret field, never in a display name. ## Save and inspect Save the model and explicitly select it in a conversation. Check the displayed model ID. After reviewing cost, you can send a short prompt; no live request was performed here, and there are no verified MonkeyAI screenshots to reuse. Appearance in a dropdown does not establish connectivity. ## Troubleshooting and recovery For 401, check the complete key; for 403, check official-client-only group restrictions; for model_not_found, check the group and ID; for 404 or protocol errors, check Responses / Messages support and URL construction. Use the matching CLI if the custom provider lacks the protocol instead of inventing configuration fields. Remove the failed custom entry or switch back to an existing model. Redact keys, account information and private conversations from diagnostic screenshots. Source: https://monkeytheme.com/en/docs/openclaw # Manually connect OpenClaw to MonkeyAI ## Select an external-use channel Create a dedicated key in [key management](https://monkeytheme.com/keys). For Claude, choose `Claude Plus(精品)`, `Claude Max(外接版)` or a suitable official direct group. For Codex, choose `Codex Pro(外接版)` or external-capable Lite. Neither `Claude Max(仅限CC)` nor `Codex Pro(仅限Codex)` allows OpenClaw. Lite has no free Fast tier. Review [pricing](https://monkeytheme.com/custom/billing-pricing) before requests. | Channel | Base | Example model | Required protocol | | --- | --- | --- | --- | | Claude | https://monkeytheme.com | claude-opus-4-8 | Anthropic Messages | | Codex | https://monkeytheme.com/v1 | gpt-6.1-sol | OpenAI Responses | The models appear in the relevant groups in the current model listing. This does not establish compatibility with every OpenClaw release. ## Installation Prepare [Node.js](/en/docs/nodejs). OpenClaw requires Node 24.x at least 24.16, or 26.1+; security guidance recommends 24.22.1+ or 26.12.1+. Use npm 12 or 11.16+ for the commands below; omit `--allow-scripts=openclaw` on older npm. See the [official installation guide](https://docs.openclaw.ai/install). Native Windows and WSL are supported; WSL is optional. ### Windows ```powershell npm install -g openclaw@latest --allow-scripts=openclaw openclaw --version openclaw onboard ``` ### macOS ```bash npm install -g openclaw@latest --allow-scripts=openclaw openclaw --version openclaw onboard ``` ### Linux ```bash npm install -g openclaw@latest --allow-scripts=openclaw openclaw --version openclaw onboard ``` ## Manual interactive setup Back up existing settings. Run `openclaw onboard`, choose Custom setup → More… / Custom Provider, and explicitly select custom access instead of reusing official OAuth. Enter the base, key, compatibility protocol and model from the table. Choose Anthropic Messages for Claude. Choose Responses for Codex only if your release offers it; Chat Completions cannot become Responses by changing a model ID. The wizard performs real model verification before saving, which may incur usage charges. See the [official wizard guide](https://docs.openclaw.ai/start/wizard). A visible text model does not establish tool compatibility. ## Launch and permissions Use the launch path shown by your release. Inspect `openclaw --help` first. Check the active default model and provider. Validate in an empty workspace before granting the file, tool and messaging permissions your task needs. ## Verification, troubleshooting and recovery A short user-run request may incur charges. Check the key for 401, external-use group for 403, protocol and base for 404, and exact model for model_not_found. Keep redacted errors and version information without sharing secret configuration. Restore the earlier provider or backup using supported client controls if necessary. See [Hermes](/en/docs/hermes) for another agent path. Source: https://monkeytheme.com/en/docs/hermes # Configure Hermes Agent with the interactive wizard ## Requirements and key groups Hermes is an independent agent and requires an external-use MonkeyAI key. In [key management](https://monkeytheme.com/keys), choose `Claude Plus(精品)`, `Claude Max(外接版)` or a suitable official direct group. For GPT, choose `Codex Pro(外接版)` or external-capable Lite. Do not use `Claude Max(仅限CC)` or `Codex Pro(仅限Codex)`. Lite has no free Fast tier and lists no image models. Review [live pricing](https://monkeytheme.com/custom/billing-pricing). ## Installation The [official installation guide](https://hermes-agent.nousresearch.com/docs/getting-started/installation) supports native Windows, macOS including Apple Silicon, and Linux; WSL is optional. Download the official script, review it, then execute it. Reopen the terminal afterward and run `hermes --help`. ### Windows ```powershell Invoke-WebRequest https://hermes-agent.nousresearch.com/install.ps1 -OutFile hermes-install.ps1 Get-Content .\hermes-install.ps1 # Execute after reviewing the script & .\hermes-install.ps1 ``` ### macOS ```bash curl -fsSL https://hermes-agent.nousresearch.com/install.sh -o hermes-install.sh less hermes-install.sh # Execute after reviewing the script bash hermes-install.sh ``` ### Linux ```bash curl -fsSL https://hermes-agent.nousresearch.com/install.sh -o hermes-install.sh less hermes-install.sh # Execute after reviewing the script bash hermes-install.sh ``` ## Run hermes model Use the confirmed interactive model setup entry: ```text hermes model ``` Choose a provider with a customizable endpoint or a custom API in the wizard. Enter the following values when prompted; exact labels vary by release: | Setting | Claude path | Codex path | | --- | --- | --- | | API protocol | Anthropic Messages | OpenAI Responses | | Base | https://monkeytheme.com | https://monkeytheme.com/v1 | | Model ID | claude-opus-4-8 | gpt-6.1-sol | | Key | Enter your own key privately | Enter your own key privately | Do not append `/v1/messages` to the Claude base. Confirm that the Codex path supports Responses; a custom OpenAI option meaning only Chat Completions is insufficient. If the required protocol is unavailable, stop that path, check the release or use a supported Claude path. Do not enter a MonkeyAI key into an official OAuth login flow. ## Save and launch Review the wizard's saved provider and model, then run `hermes`. Restart existing sessions. Configure under the same user and environment that runs Hermes on Windows, WSL, macOS or Linux. Use the interactive wizard to save settings; no manual configuration file is needed. ## Verification and recovery After reviewing [pricing](https://monkeytheme.com/custom/billing-pricing), you can ask a short question in an empty directory. Check the key for 401, external-use group for 403, protocol and URL for 404, and exact ID for model_not_found. Diagnose tool failures separately from text request failures: text access does not establish compatibility with every tool, image operation or long-running task. Run `hermes model` again to restore the previous provider, and retain redacted errors for troubleshooting. See [image generation](/en/docs/image-gen) for image capabilities. Source: https://monkeytheme.com/en/docs/api-scripts # MonkeyAI API scripts: text, vision and images ## Credentials and runtime [Register](https://monkeytheme.com/register) or [sign in](https://monkeytheme.com/login), then create a group-specific key under [API keys](https://monkeytheme.com/keys). Keep credentials in the script process environment, outside source code, browser applications and commits. Running them sends requests and may incur charges. For Python 3, install `python3 -m pip install openai anthropic`. For Node.js, use an LTS release supported by the current SDKs and install `npm install openai @anthropic-ai/sdk`. Use the official SDK packages. ```bash export MONKEYAI_API_KEY="YOUR_API_KEY" ``` ```powershell $env:MONKEYAI_API_KEY="YOUR_API_KEY" ``` ## Protocol and group selection | Protocol | Stable path | Model used here | | --- | --- | --- | | Responses | `POST /v1/responses` | `gpt-6.1-sol` | | Chat Completions | `POST /v1/chat/completions` | `gpt-6.1-sol` | | Messages | `POST /v1/messages` | `claude-opus-4-8` | Use `https://monkeytheme.com/v1` as the OpenAI SDK base and `https://monkeytheme.com` as the Anthropic SDK base. The latter appends `/v1/messages`. Avoid duplicating `/v1`. Both model IDs are listed for the relevant groups. Scripts need Codex Pro external access, GPT direct access or a Claude group that permits external clients. Groups restricted to Codex or CC are not general script credentials. A listing does not establish access for every key or verify every vision, tool or protocol feature. Gemini native routing uses `/v1beta/`; swapping a model name does not translate its payload into these three protocols. ## Python: text, vision and streaming across three protocols Save as `api_demo.py`. Arguments select protocol, input and delivery, for example `python3 api_demo.py responses text plain`. For `vision`, provide your own static `input.png` in the current directory. Select `stream` instead of `plain` for streaming. All three protocols include text and vision branches. They demonstrate request structures; vision compatibility for the selected group still requires verification. ```python import base64 import os import sys from pathlib import Path from openai import OpenAI, APIError from anthropic import Anthropic, APIError as AnthropicError # python api_demo.py responses|chat|messages text|vision plain|stream protocol, mode, delivery = sys.argv[1:] if protocol not in {"responses", "chat", "messages"}: raise ValueError("Unknown protocol") if mode not in {"text", "vision"} or delivery not in {"plain", "stream"}: raise ValueError("Invalid mode or delivery") streaming = delivery == "stream" key = os.environ["MONKEYAI_API_KEY"] image = None if mode == "vision": image = base64.b64encode(Path("input.png").read_bytes()).decode("ascii") try: if protocol == "messages": client = Anthropic(api_key=key, base_url="https://monkeytheme.com", timeout=120.0, max_retries=0) content = [{"type": "text", "text": "Describe the visible evidence."}] if image: content.append({"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": image}}) args = dict(model="claude-opus-4-8", max_tokens=600, messages=[{"role": "user", "content": content}]) if streaming: with client.messages.stream(**args) as events: for text in events.text_stream: print(text, end="", flush=True) final = events.get_final_message() print("\nusage:", final.usage) else: result = client.messages.create(**args) for block in result.content: if block.type == "text": print(block.text) print("usage:", result.usage) else: client = OpenAI(api_key=key, base_url="https://monkeytheme.com/v1", timeout=120.0, max_retries=0) if protocol == "responses": content = [{"type": "input_text", "text": "Describe the visible evidence."}] if image: content.append({"type": "input_image", "image_url": "data:image/png;base64," + image}) result = client.responses.create(model="gpt-6.1-sol", input=[{"role": "user", "content": content}], stream=streaming) if streaming: with result as events: for event in events: if event.type == "response.output_text.delta": print(event.delta, end="", flush=True) elif event.type in {"error", "response.failed", "response.incomplete"}: raise RuntimeError(str(event)) elif event.type == "response.completed": print("\nusage:", event.response.usage) else: print(result.output_text) print("usage:", result.usage) else: content = [{"type": "text", "text": "Describe the visible evidence."}] if image: content.append({"type": "image_url", "image_url": { "url": "data:image/png;base64," + image}}) result = client.chat.completions.create(model="gpt-6.1-sol", messages=[{"role": "user", "content": content}], stream=streaming) if streaming: with result as chunks: for chunk in chunks: if chunk.choices: print(chunk.choices[0].delta.content or "", end="", flush=True) else: print(result.choices[0].message.content) print("usage:", result.usage) except (APIError, AnthropicError, OSError, RuntimeError) as error: print("Request failed:", error, file=sys.stderr) sys.exit(1) ``` ## Node.js: the same input and delivery combinations Save as `api_demo.mjs`, then use arguments such as `node api_demo.mjs messages vision stream`. SSE is not one JSON document. Let the SDK parse event boundaries and append only text deltas. ```javascript import fs from "node:fs/promises"; import OpenAI from "openai"; import Anthropic from "@anthropic-ai/sdk"; // node api_demo.mjs responses|chat|messages text|vision plain|stream try { const [protocol, mode, delivery] = process.argv.slice(2); if (!["responses", "chat", "messages"].includes(protocol) || !["text", "vision"].includes(mode) || !["plain", "stream"].includes(delivery)) { throw new Error("Invalid protocol, mode or delivery"); } const apiKey = process.env.MONKEYAI_API_KEY; if (!apiKey) throw new Error("Set MONKEYAI_API_KEY"); const stream = delivery === "stream"; const image = mode === "vision" ? (await fs.readFile("input.png")).toString("base64") : null; if (protocol === "messages") { const client = new Anthropic({apiKey, baseURL: "https://monkeytheme.com", timeout: 120000, maxRetries: 0}); const content = [{type: "text", text: "Describe the visible evidence."}]; if (image) content.push({type: "image", source: { type: "base64", media_type: "image/png", data: image}}); const args = {model: "claude-opus-4-8", max_tokens: 600, messages: [{role: "user", content}]}; if (stream) { const events = client.messages.stream(args); for await (const event of events) { if (event.type === "content_block_delta" && event.delta.type === "text_delta") process.stdout.write(event.delta.text); } console.log("\nusage:", (await events.finalMessage()).usage); } else { const result = await client.messages.create(args); for (const block of result.content) if (block.type === "text") console.log(block.text); console.log("usage:", result.usage); } } else { const client = new OpenAI({apiKey, baseURL: "https://monkeytheme.com/v1", timeout: 120000, maxRetries: 0}); if (protocol === "responses") { const content = [{type: "input_text", text: "Describe the visible evidence."}]; if (image) content.push({type: "input_image", image_url: `data:image/png;base64,${image}`}); const result = await client.responses.create({model: "gpt-6.1-sol", input: [{role: "user", content}], stream}); if (stream) { for await (const event of result) { if (event.type === "response.output_text.delta") process.stdout.write(event.delta); if (["error", "response.failed", "response.incomplete"].includes(event.type)) throw new Error(JSON.stringify(event)); if (event.type === "response.completed") console.log("\nusage:", event.response.usage); } } else { console.log(result.output_text); console.log("usage:", result.usage); } } else { const content = [{type: "text", text: "Describe the visible evidence."}]; if (image) content.push({type: "image_url", image_url: {url: `data:image/png;base64,${image}`}}); const result = await client.chat.completions.create({model: "gpt-6.1-sol", messages: [{role: "user", content}], stream}); if (stream) { for await (const chunk of result) process.stdout.write(chunk.choices[0]?.delta?.content ?? ""); } else { console.log(result.choices[0].message.content); console.log("usage:", result.usage); } } } } catch (error) { console.error("Request failed:", error.status ?? "", error.message); process.exitCode = 1; } ``` ## Completion and usage in streams For Responses, append `response.output_text.delta` and inspect completion usage; failed and incomplete events must remain failures. For Messages, collect text blocks and retrieve the final message. Chat chunks can have no choices or empty deltas; the example handles both. Chat streams do not always include usage. Once your group supports it, request `stream_options: {include_usage: true}` and read the final usage chunk; otherwise reconcile against account usage records. Treat interrupted output as partial. Production applications should track completion, stop reasons and available request IDs, and close streams when cancelling. Tool calls need separate argument accumulation and validation; these examples do not invoke tools. Retrying after receiving partial output can duplicate work and charges. ## Image generation and editing The model listing lists `gpt-image-2` in Codex Pro external access and the ChatGPT image group; Codex Lite does not list it. These examples use the stable `/v1/images/generations` and `/v1/images/edits` paths. The SDK sends edit input as multipart. The listing alone does not verify editing, masks, dimensions or response formats on the selected channel; those remain unverified. The code requires Base64 output and fails explicitly for URL-only output rather than downloading an unknown address. Save the Python program as `image_demo.py` and the Node.js program as `image_demo.mjs`. Pass `generate` or `edit`; edits need your own `input.png`. The output overwrites `output.png` in the current directory, so preserve any existing file first. No video availability is guaranteed by the available evidence. ```python import base64 import os import sys from pathlib import Path from openai import OpenAI, APIError # python image_demo.py generate|edit try: client = OpenAI(api_key=os.environ["MONKEYAI_API_KEY"], base_url="https://monkeytheme.com/v1", timeout=180.0, max_retries=0) mode = sys.argv[1] if mode == "generate": result = client.images.generate(model="gpt-image-2", prompt="A paper sculpture of a mountain, plain background", n=1) elif mode == "edit": with open("input.png", "rb") as image: result = client.images.edit(model="gpt-image-2", image=image, prompt="Change the background to pale blue; preserve the subject", n=1) else: raise ValueError("Use generate or edit") if not result.data or not result.data[0].b64_json: raise RuntimeError("No Base64 image returned; inspect the response format safely") Path("output.png").write_bytes(base64.b64decode(result.data[0].b64_json, validate=True)) print("Saved output.png") except (APIError, OSError, ValueError, RuntimeError) as error: print("Image request failed:", error, file=sys.stderr) sys.exit(1) ``` ```javascript import fs from "node:fs"; import OpenAI from "openai"; try { if (!process.env.MONKEYAI_API_KEY) throw new Error("Set MONKEYAI_API_KEY"); const client = new OpenAI({apiKey: process.env.MONKEYAI_API_KEY, baseURL: "https://monkeytheme.com/v1", timeout: 180000, maxRetries: 0}); const mode = process.argv[2]; let result; if (mode === "generate") { result = await client.images.generate({model: "gpt-image-2", prompt: "A paper sculpture of a mountain, plain background", n: 1}); } else if (mode === "edit") { result = await client.images.edit({model: "gpt-image-2", image: fs.createReadStream("input.png"), prompt: "Change the background to pale blue; preserve the subject", n: 1}); } else throw new Error("Use generate or edit"); if (!result.data?.[0]?.b64_json) throw new Error("No Base64 image returned; inspect response format safely"); fs.writeFileSync("output.png", Buffer.from(result.data[0].b64_json, "base64")); console.log("Saved output.png"); } catch (error) { console.error("Image request failed:", error.status ?? "", error.message); process.exitCode = 1; } ``` ## Large file input A local path is not file content. Extract text from PDF or office documents locally; scanned pages require OCR. Read UTF-8 text with Python `Path("document.txt").read_text(encoding="utf-8")` or Node.js `await fs.readFile("document.txt", "utf8")`, then place it in the example's text block. Do not put arbitrary binary bytes in text. Uploads, file IDs, automatic URL retrieval and native PDF input remain unverified for these groups; do not assume `/v1/files` is enabled. Split large documents at meaningful boundaries, keep segment IDs and aggregate results later. Base64 images increase body size as well as the input budget. Confirm exact file, image and context limits for the selected channel. ## Billing and troubleshooting Use [live pricing](https://monkeytheme.com/custom/billing-pricing) and account usage records. Input, output, caching and images may have different billing rules; group multipliers and long context rules can also matter. A per-image rate is not a text token rate, and missing stream usage does not mean free usage. | Symptom | Action | | --- | --- | | 401 / 403 | Check environment, key validity, balance and group client restrictions; never log Authorization | | 404 / model_not_found | Check exact model ID, path and group; avoid duplicate `/v1` | | 400 / 422 | Check protocol-specific content blocks, image MIME type and optional fields; remove unsupported options | | 413 / context exceeded | Resize images, extract text or split input; characters are not tokens | | 429 / 503 | Reduce concurrency, respect Retry-After and use bounded exponential backoff | | Timeout / interruption | Check connectivity and proxies; mark partial output and inspect billing before retrying | | Empty image output | Check image group permissions and return format; never fabricate an image or success result | Redact user content before logging errors. SDK automatic retries are disabled so examples do not silently repeat requests. Handle HTTP, transport and in-stream failures. Exact SDK compatibility, live channel behavior and end-to-end vision/editing results depend on the selected channel and client version. Source: https://monkeytheme.com/en/docs/image-gen # Generate and edit images with MonkeyAI ## Confirm the model and key group Create a dedicated image key in [key management](https://monkeytheme.com/keys) and review [live pricing](https://monkeytheme.com/custom/billing-pricing). The table follows the current model listing; group descriptions do not establish tested API parameters. | Group | Listed image models | Limits | | --- | --- | --- | | Codex Pro(外接版) | gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst | External use allowed; generation/edit parameters still need verification | | ChatGPT 生图分组 | gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst | Dedicated image group | | Gemini (官方直连) | gemini-2.5-flash-image, gemini-3.1-flash-image, gemini-3.1-flash-lite-image, gemini-nano-banana-2.1 | Native Gemini protocol; check response format | `Codex Pro(仅限Codex)` explicitly forbids image generation. Codex Lite currently lists no image models. Although the Grok enterprise description advertises images and video, its model list contains no dedicated image ID; this guide does not promise access to `grok-imagine-image` or its quality variant. The current Gemini listing also lacks `gemini-3-pro-image`. MonkeyAI has no Muse/Hunyuan groups, so their availability is not promised. ## Prepare a client or skill manually Do not paste a real key into chat. If you already have a trusted image client or skill, inspect its origin, protocol support, custom base configuration and key handling. Otherwise, use the [API scripts guide](/en/docs/api-scripts) to check interfaces before installing unknown scripts. The OpenAI-compatible base is `https://monkeytheme.com/v1`. Native Gemini routes use `/v1beta/`, typically with the root URL as the client's base. Verify generation and editing endpoints and parameters for the chosen model. Do not mix Responses, Images and Gemini fields in one request. A visible model listing does not prove that generation and editing both work. ## Prepare the key on Windows, macOS and Linux If your trusted tool explicitly supports `IMAGE_GEN_API_KEY`, set it in the parent terminal. Windows PowerShell placeholder example: ```powershell $env:IMAGE_GEN_API_KEY = "YOUR_API_KEY" ``` macOS / Linux: ```bash export IMAGE_GEN_API_KEY="YOUR_API_KEY" ``` This variable is a tool convention, not a standard automatically recognized by every client. Map it according to the tool's instructions and launch the tool from that terminal to inherit it. GUI programs may not inherit shell variables; use their secure key input instead. Keep real keys out of prompts, source code and Git. ## Describe three distinct image tasks Text to image: “Create a blue and white product poster with a centered subject, space for a title at the top and no added text. Use gpt-image-2 and first identify the group and dimensions you will use.” Reference image: “Create a new composition from my reference image. Preserve the subject silhouette and palette, but change the background and viewpoint. Confirm first that the selected model accepts image input.” Image editing: “Change only the uploaded image's background to pale blue. Preserve subject position, proportions and existing text. Explain any limitation if local editing is unsupported.” These prompts express tasks; they do not install a skill or guarantee a particular API call. Check the key group before switching models. Use reference files you are entitled to process and inspect which files the client will upload. ## Handle results, troubleshoot and assess output Inspect whether the tool returns an image URL, base64 or Gemini content blocks instead of assuming one format. URLs may expire: save the output, verify that it opens, then compare the subject, lettering and edited area. Dimensions, count, transparency and reference-image limits were not validated here; arbitrary values are not promised. Image requests are billed according to actual usage. Check the key for 401, group for 403 and model ID for model_not_found. For format errors, inspect protocol and model input limits. A tool without image support cannot be fixed merely by renaming a text model. Share redacted errors and model IDs, keeping keys private. See [API scripts](/en/docs/api-scripts) for programmatic integration. Source: https://monkeytheme.com/en/docs/typesafe # MonkeyAI TypeSafe: structured decisions and scoring ## Endpoint, credentials and current version TypeSafe handles decisions, classification and scoring through `POST https://monkeytheme.com/v1/systemone`. It returns a complete JSON response, rather than chat messages or a stream. [Register](https://monkeytheme.com/register) or [sign in](https://monkeytheme.com/login), then select a TypeSafe group key under [API keys](https://monkeytheme.com/keys). **The current backend accepts only `jev-latest`.** The model plaza also lists `jev-1.13.0` and `jev-1.14.0`, but pinned versions are not currently guaranteed to be callable. A listing is not proof that a version can be called. All requests here use `jev-latest`, without asserting its current version mapping. For reproducibility, retain the request, timestamp and returned model, and confirm version support first. No example was sent to the service and no response values are fabricated. Running these scripts transmits your data and may incur charges. Read keys from the environment; keep them out of browser code and Git. ```bash export TYPESAFE_API_KEY="YOUR_API_KEY" ``` ```powershell $env:TYPESAFE_API_KEY="YOUR_API_KEY" ``` Minimal Bash/WSL cURL request (requires the environment variable; running it sends a request): ```bash curl --fail-with-body --connect-timeout 15 --max-time 120 "https://monkeytheme.com/v1/systemone" -H "Authorization: Bearer $TYPESAFE_API_KEY" -H "Content-Type: application/json" --data-binary '{"model":"jev-latest","state":"Please replace my damaged parcel.","questions":{"replacement":{"type":"noul","instructions":"Is a replacement requested?"}}}' ``` ## state, questions and answer structure Supply `model`, `state` and a nonempty `questions` object. State holds the material as a string, object or array. Question keys are your result IDs; each question's `instructions` defines the task. The response's `answers` uses those IDs. Do not send `messages`, `prompt` or `stream=true`. Image assets belong in top-level `assets`. | type | criteria | Reading the result | | --- | --- | --- | | `noul` | Optional object with `true` / `false` descriptions | `answers.ID.noul` is a probability from 0 to 1, not a boolean; apply a calibrated application threshold | | `choice` | Object mapping option IDs to descriptions; reference protocol allows 1–255 | `answers.ID.choice` identifies an option; also inspect confidence and probabilities | | `score` | Ordered descriptions from low to high; reference protocol allows 1–10 levels indexed from 0 | `answers.ID.score` is a probability-weighted score and can be fractional; inspect legend, confidence and probabilities | | `box` | Instructions identify one specific target | Experimental image localization; current MonkeyAI availability is unverified | Questions share state but are evaluated independently. A question cannot depend on another question's answer within the same request. Implement dependent stages as separate application calls. Confidence and probability are different measures. Calibrate thresholds such as 0.8 using your own validation set; probability is not a boolean or a guaranteed accuracy figure. ## Python: decisions, classification, scoring and file mode Python 3 requires only its standard library. Save as `typesafe_demo.py` and run `python3 typesafe_demo.py text` for text or `python3 typesafe_demo.py file` for a local document. Image mode is an unverified example: confirm channel support before using it. The program prints actual responses rather than assuming successful answers. ```python import base64 import json import os import sys import urllib.error import urllib.request import uuid from pathlib import Path # python typesafe_demo.py text|file|image def evaluate(body): request = urllib.request.Request( "https://monkeytheme.com/v1/systemone", data=json.dumps(body, ensure_ascii=False).encode("utf-8"), headers={"Authorization": "Bearer " + os.environ["TYPESAFE_API_KEY"], "Content-Type": "application/json"}, method="POST") try: with urllib.request.urlopen(request, timeout=120) as response: result = json.load(response) except urllib.error.HTTPError as error: # Do not log credentials or private request contents. raise RuntimeError(f"HTTP {error.code}; inspect a redacted error body locally") from error if not isinstance(result.get("answers"), dict): raise ValueError("Response has no answers object") return result try: mode = sys.argv[1] body = {"model": "jev-latest", "state": {"note": "The delivery arrived damaged. Can someone arrange a replacement this week?"}, "questions": { "replacement": {"type": "noul", "instructions": "Is a replacement requested?", "criteria": {"true": "A replacement is requested.", "false": "No replacement is requested."}}, "route": {"type": "choice", "instructions": "Select the responsible team.", "criteria": {"delivery": "Damaged or missing deliveries.", "account": "Account access.", "other": "Other issues."}}, "priority": {"type": "score", "instructions": "Assess the stated time pressure.", "criteria": ["No deadline.", "Within a week.", "Immediate action required."]}}} if mode == "file": body["state"] = Path("document.txt").read_text(encoding="utf-8") body["questions"] = {"renewal": {"type": "noul", "instructions": "Does the document require an explicit renewal decision?"}} elif mode == "image": # Unverified on MonkeyAI: confirm image capability before using this mode. ref = str(uuid.uuid4()) body["state"] = {"photo": ref} body["assets"] = {ref: {"type": "image", "format": "png", "data_base64": base64.b64encode(Path("input.png").read_bytes()).decode("ascii")}} body["questions"] = {"label_visible": {"type": "noul", "instructions": "Is a shipping label visible in the image?"}} elif mode != "text": raise ValueError("Use text, file or image") result = evaluate(body) print(json.dumps(result, ensure_ascii=False, indent=2)) if mode == "text": probability = result["answers"]["replacement"]["noul"] if isinstance(probability, bool) or not isinstance(probability, (int, float)) or not 0 <= probability <= 1: raise ValueError("Invalid noul probability") # 0.8 is an illustrative policy threshold, not a service guarantee. print("Review for replacement:", probability >= 0.8) print("usage:", result.get("usage")) except (OSError, ValueError, KeyError, TypeError, RuntimeError) as error: print("TypeSafe request failed:", error, file=sys.stderr) sys.exit(1) ``` ## Node.js: the same tasks without dependencies Use Node.js 18+ with fetch and AbortSignal.timeout, preferably a maintained LTS release. Save as `typesafe_demo.mjs`; run `node typesafe_demo.mjs text`, `file`, or `image` after confirming support. HTTP, JSON, file and timeout errors reach the error handler. There are no automatic retries that silently add requests. ```javascript import fs from "node:fs/promises"; import {randomUUID} from "node:crypto"; // node typesafe_demo.mjs text|file|image async function evaluate(body) { const key = process.env.TYPESAFE_API_KEY; if (!key) throw new Error("Set TYPESAFE_API_KEY"); const response = await fetch("https://monkeytheme.com/v1/systemone", { method: "POST", headers: {Authorization: `Bearer ${key}`, "Content-Type": "application/json"}, body: JSON.stringify(body), signal: AbortSignal.timeout(120000) }); if (!response.ok) throw new Error(`HTTP ${response.status}; inspect a redacted error body locally`); const result = await response.json(); if (!result.answers || typeof result.answers !== "object" || Array.isArray(result.answers)) throw new Error("Response has no answers object"); return result; } try { const mode = process.argv[2]; const body = {model: "jev-latest", state: {note: "The delivery arrived damaged. Can someone arrange a replacement this week?"}, questions: { replacement: {type: "noul", instructions: "Is a replacement requested?", criteria: {true: "A replacement is requested.", false: "No replacement is requested."}}, route: {type: "choice", instructions: "Select the responsible team.", criteria: {delivery: "Damaged or missing deliveries.", account: "Account access.", other: "Other issues."}}, priority: {type: "score", instructions: "Assess the stated time pressure.", criteria: ["No deadline.", "Within a week.", "Immediate action required."]} }}; if (mode === "file") { body.state = await fs.readFile("document.txt", "utf8"); body.questions = {renewal: {type: "noul", instructions: "Does the document require an explicit renewal decision?"}}; } else if (mode === "image") { // Unverified on MonkeyAI: confirm image capability before using this mode. const ref = randomUUID(); body.state = {photo: ref}; body.assets = {[ref]: {type: "image", format: "png", data_base64: (await fs.readFile("input.png")).toString("base64")}}; body.questions = {label_visible: {type: "noul", instructions: "Is a shipping label visible in the image?"}}; } else if (mode !== "text") throw new Error("Use text, file or image"); const result = await evaluate(body); console.log(JSON.stringify(result, null, 2)); if (mode === "text") { const probability = result.answers.replacement.noul; if (typeof probability !== "number" || probability < 0 || probability > 1) throw new Error("Invalid noul probability"); console.log("Review for replacement:", probability >= 0.8); } console.log("usage:", result.usage); } catch (error) { console.error("TypeSafe request failed:", error.message); process.exitCode = 1; } ``` ## Image input and Box: unverified capabilities Image mode illustrates the reference JSON + Base64 structure: create a UUID, place `type: image`, `format: png` and plain `data_base64` under assets, then reference the UUID from state.photo. Base64 must have no data URL prefix or line breaks. For JPEG, change both the filename and format to jpg or jpeg. Repeated references may expand input; reference a shared image once in state where possible. URLs and local paths are not image bytes, and automatic retrieval must not be assumed. Multipart, SDK uploads and compressed bodies remain unverified here. The reference describes static PNG/JPEG, dimensions of 280–1568 pixels per side, a 16 MiB image limit and a 32 MiB body limit. **These are not verified MonkeyAI limits or capacity promises.** Confirm supported formats, dimensions and limits for the gateway and current alias. Correct orientation, resize or pad if necessary; Base64 adds roughly a third to byte size. This does not establish animation or video support. Box is also unverified. A plaza listing for 1.14.0 establishes neither callable version support nor localization capability. After verification, a question would have the illustrative shape below; this is a fragment, not a standalone request or an instruction to enable it in production: ```json {"target": {"type": "box", "instructions": "Locate the shipping label in the referenced image."}} ``` Reference coordinates are normalized left/top/right/bottom, with the origin at the top left. For submitted width W and height H, the pixel box is `(left×W, top×H, right×W, bottom×H)`. Round, clamp and map back after resizing or cropping. A box may be returned when the target is absent, so first assess presence with noul before accepting coordinates. A null confidence is not zero. Use explicit single-target questions for multiple objects. This explains the protocol without asserting live Box availability. ## Large files and context boundaries Prepare UTF-8 `document.txt` in the current directory. File mode in both languages reads its contents into state and asks whether an explicit renewal decision is required. A filename or URL alone is not read. Extract text or use OCR locally for PDF, office files and scans; do not decode arbitrary binary data as UTF-8. The reference mentions a 262K-token limit for the whole request and for state plus one question. Confirm the context limit, gateway body limit and long context billing for MonkeyAI's current `jev-latest`; reference limits are not MonkeyAI capacity guarantees. Budget for state, questions and images; characters are not tokens. Split large documents into identified sections and aggregate in your application. Cross-section dependencies can affect decisions: absence from one segment does not establish absence from the entire document. ## Usage and billing Read `usage.input_tokens` and `usage.output_tokens`, then reconcile with [live pricing](https://monkeytheme.com/custom/billing-pricing) and account usage records. TypeSafe lists token billing with zero output price; effective rates still depend on current group rules. If input-only billing is confirmed, estimate input tokens divided by 1,000,000 times the effective price per million input tokens. Rounded display prices are unsuitable for precise reconciliation. Do not promise no image surcharge or unchanged long context rates without confirmation. Images affect input usage; inspect records rather than guessing how failures or retries were charged. ## Troubleshooting and readiness checks | Symptom | Check and action | | --- | --- | | 401 / 403 | Check environment, complete key, expiry, balance and TypeSafe group; never print keys | | 404 / protocol error | Use `/v1/systemone`; Chat, Responses and Messages are not substitutes | | model_not_found / rejected pinned version | Use only `jev-latest` currently; pinned versions are not guaranteed to be callable, so do not loop on a rejected version | | 400 / 422 | Validate nonempty questions, state, type, instructions and criteria; omit stream; check image encoding and references | | 413 | Reduce files or images, allow for Base64 expansion and gateway limits, and split requests | | max_tokens_exceeded | Reduce state, questions and images together; avoid duplicate references and confirm the actual context limit | | 429 / 503 | Reduce concurrency and apply bounded backoff following Retry-After when present; retain redacted request IDs for support | | Timeout / non-JSON / missing answers | Mark failure, retain redacted status and content type, inspect the gateway response and never synthesize answers | Before use, confirm alias mapping, response fields, image and Box support, input limits, runtime compatibility and billing. A successful text request does not establish every capability.