Te turanga matauranga Kaiwhakawhanake
Ngā Taputapu me ngā SDK
Ko ia mea e taea e OpenAI rānei Anthropic rānei te kōrerorero me ia, ka taea hoki e Nymbot te kōrerorero me ia. I ia take, he URL matua, he tuhinga raweke, he ingoa tauira hoki.
He mihini tenei wharangi kia pai ai. Ko te reo Ingarihi taketake te putanga e tika ana.
Ko ia whakarite i raro i tenei e hiahia ana i tētahi API key, i hangaia i roto i te app. API menū (titiro
Ngā tuhingā API), me he id tauira i
te rārangi tauira. He whakamahinga ngā tauira
anthropic/claude-sonnet-5 i runga i te tauhanga Pro. nymbot/auto Ko te kōwhiringa iti utu ake i runga i te taupānga tūāpapa mō te kōrerorero noa, engari e kore e taea te whakamahi i ngā taputapu, e hiahia ana a Goose; mō tēnā, kōwhiria he tauira rārangi me capabilities.tools.
Ko te whakamahau mō ngā pūmanawa tūhono kōnae pēnei i a Claude Code, Codex, Cline, Kilo Code me te Continue kei tōna ake whāpage: ngā taputapu tūhono rorohiko.
Whāia he tuhinga motuhake mō ia taputapu, me tētahi rāhui. Ka waiho ngā kaitatari rorohiko i ngā wāhanga maha mō tētahi mahi kotahi, ā ko te rāhui i runga i te tuhinga te huarahi pai rawa ki te mōhiotia te nui rawa o te utu e taea e tētahi taputapu kia whai ake ai. Ki te hē te mahi a tētahi taputapu, whakakore i tōna tuhinga ā, kāore he mea atu e pā ana.
OpenAI SDK
E mahi ana ngā whakaharahara Python me JavaScript kaore i te rerekē. Point base_url ki
Nymbot ka tuku i tō kī. Ka mahi ngā Chat Completions, ngā Whakautu, ngā whakaahua, ngā rongo, me ngā embeddings katoa
mā rātou.
cURL
curl https://nymbot.ai/api/v1/chat/completions \
-H "Authorization: Bearer $NYMBOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "anthropic/claude-sonnet-5", "messages": [{"role": "user", "content": "Hello"}]}'
Python
# pip install openai
import os
from openai import OpenAI
client = OpenAI(base_url="https://nymbot.ai/api/v1", api_key=os.environ["NYMBOT_API_KEY"])
reply = client.chat.completions.create(
model="anthropic/claude-sonnet-5",
messages=[{"role": "user", "content": "Hello"}],
)
print(reply.choices[0].message.content)
JavaScript
// npm install openai
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://nymbot.ai/api/v1", apiKey: process.env.NYMBOT_API_KEY });
const reply = await client.chat.completions.create({
model: "anthropic/claude-sonnet-5",
messages: [{ role: "user", content: "Hello" }],
});
console.log(reply.choices[0].message.content);
Ngā rauemi ake a plugins mō te rapu web, haere ki roto extra_body
ki roto i te Python me te tika atu ki te tautoko tono i roto i te JavaScript. Te nymbot te utu
he mea i roto i tētahi whakautu koia tēnei reply.model_extra["nymbot"] i te Python me
reply.nymbot i roto i te JavaScript. Ngā pāngarau e pānui ana i te OPENAI_BASE_URL
a OPENAI_API_KEY ka taea te whakawhiti atu ki a Nymbot mā ngā rārangi taunaha anake.
Anthropic SDK
Kei te whakamahi ngā whaihanga Anthropic i te https://nymbot.ai/api hei te tūāpapa URL, kore
/v1, nā te mea ka tāpiri rātou /v1/messages rātou anake. He aha rā te mahere kōpaki
e mahi ana, ehara i te Claude anake.
cURL
curl https://nymbot.ai/api/v1/messages \
-H "x-api-key: $NYMBOT_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model": "claude-sonnet-5", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]}'
Python
# pip install anthropic
import os
import anthropic
client = anthropic.Anthropic(base_url="https://nymbot.ai/api", api_key=os.environ["NYMBOT_API_KEY"])
message = client.messages.create(
model="claude-sonnet-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(message.content[0].text)
JavaScript
// npm install @anthropic-ai/sdk
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://nymbot.ai/api", apiKey: process.env.NYMBOT_API_KEY });
const message = await client.messages.create({
model: "claude-sonnet-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});
console.log(message.content[0].text);
Āwhina
Ka taea e Aider te kōrero ki tētahi tūmahi OpenAI-compatible katoa. Whakasetokia te tūāpapa URL me te kī, ā, whakauruia
openai/ i mua i te id o te tauira kia mōhio ai a Aider he aha te momo tūmatanui kei te mea nei:
Shell
export OPENAI_API_BASE=https://nymbot.ai/api/v1
export OPENAI_API_KEY=sk-nymbot-...
aider --model openai/anthropic/claude-sonnet-5
Ka taea e Aider te whakamātau ko te mea kāore ia e mōhiotia te nui o te kontekiti o te tauira me te utu. He whakamātau kore kino tēnei;
--no-show-model-warnings whakamātau i tōna huna.
Whakatuwhera WebUI
Ki te Open WebUI, whakatuwhera Panepane Kaiwhakahaere, ka tino Tautuhinga, ka tino Hononga, ā, whakauria he hononga OpenAI API:
- URL:
https://nymbot.ai/api/v1 - Kī: tō kī API
Ka pānui a Open WebUI i te rārangi tauira i te API, nō reira ka puta katoa ngā tauira kōrero ki te kōwhiringa. I te whakahaere i roto i te Docker, ka taea hoki te whakarite i tēnei mā ngā tūtohu taiao.
OPENAI_API_BASE_URL a OPENAI_API_KEY.
Kei te noho tonu i tōna ake tūmomo tūmomo pūmanawa ngā kōrerorero a Open WebUI. Kāore e tiaki i ngā kōrerorero a Nymbot, engari ko Open WebUI e tiaki ana, i hea noa iho e whakahaere ai koe.
Anuku
Ope goose configure, kōwhiri Whakarite Whakapakari, kōwhiria
OpenAI, ā, tukuna ēnei uara ki a ia ina pātaiā. Ka taea hoki te whakarite i te mea pēnei i te
taiao:
Shell
export GOOSE_PROVIDER=openai
export OPENAI_HOST=https://nymbot.ai/api
export OPENAI_BASE_PATH=v1/chat/completions
export OPENAI_API_KEY=sk-nymbot-...
export GOOSE_MODEL=anthropic/claude-sonnet-5
goose session
Ka whakamahi a Goose i ngā taputaki i ia taumata tata koki, nō reira kōwhiria he tauira me te capabilities.tools i roto i te
rārangi tauira; nymbot/auto whakaheke i ngā taputapu.
HTTP Noa
Kāore he mea e hiahia ana ki tētahi SDK. He JSON katoa ngā huarahi mā te HTTPS, engari mō ngā whakaeke tuhinga, he multipart forms ōna. Ko tētahi reo rorohiko rānei taputapu rānei e taea ai te whakatau i tētahi tono HTTP, ka taea te whakamahi i te API:
- Tukuna te tuapapa hei
Authorization: Bearer sk-nymbot-…. - Tukuna ngā JSON bodies me te
Content-Type: application/json. - Mō te rerenga, pānui i te whakautu hei ngā tūnga ka timata mai i te tūmanako; ki te cURL, whakamahia
-Nnō reira ka puta tonu rātou i te rārangi i te wā e tae mai ana. - Pānui i te utu i te
X-Nymbot-Cost-Satsmuarangi, kia mau tonu teX-Request-Idhea ki te rāweke rānei ki te pātai mō tētahi tono.
cURL
curl -i https://nymbot.ai/api/v1/chat/completions \
-H "Authorization: Bearer $NYMBOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "nymbot/auto", "messages": [{"role": "user", "content": "Hello"}]}'
Python
import os
import requests
res = requests.post(
"https://nymbot.ai/api/v1/chat/completions",
headers={"Authorization": "Bearer " + os.environ["NYMBOT_API_KEY"]},
json={"model": "nymbot/auto", "messages": [{"role": "user", "content": "Hello"}]},
)
print(res.headers["X-Nymbot-Cost-Sats"], res.headers["X-Request-Id"])
print(res.json()["choices"][0]["message"]["content"])
JavaScript
const res = await fetch("https://nymbot.ai/api/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer " + process.env.NYMBOT_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({ model: "nymbot/auto", messages: [{ role: "user", content: "Hello" }] }),
});
console.log(res.headers.get("X-Nymbot-Cost-Sats"), res.headers.get("X-Request-Id"));
console.log((await res.json()).choices[0].message.content);