Ngā endpoint whakamuna, Tor & I2P
Ka whakaputaina hoki te API hei Tor onion service me tētahi I2P eepsite. Ngā ara ōrite, te key ōrite; ko te base URL me te proxy anake ka huri.
Ngā base URL
E whā ngā wāhitau ka tae ki te API ōrite. Whakamahia te mea e pai ana ki tō whatunga, me te API key ōrite me ngā tono ōrite.
| Whatunga | Base URL | Te āhua o te tae atu |
|---|---|---|
| Tukutuku mārama | https://api.shannon-ai.com/v1 | Tōtika, mā te HTTPS. |
| Whakaata whakamuna | https://api-encrypted.shannon-ai.com/v1 | Tōtika, mā te HTTPS. He ingoa host tuarua mō te API ōrite. |
| Tor (onion service) | http://shannonmd773o5vxz75byha5rkea7nzr3srotw46uwythq3pjl6y4cad.onion/v1 | Mā tētahi kiritaki Tor: he SOCKS5 proxy, i te taunoa ki 127.0.0.1:9050. |
| I2P (eepsite) | http://acvnvkdea4xaczzjap7chysqqi4kkvp2eorfwkasindzmjpa47da.b32.i2p/v1 | Mā tētahi router I2P: he HTTP proxy, i te taunoa ki 127.0.0.1:4444. |
- Ka tango tētahi SDK OpenAI i te base URL pēnei i te whakaaturanga, me te
/v1. Ka tango tētahi SDK Anthropic i a ia kāore he/v1. - Hei tirotiro i tētahi wāhitau, pānuitia ngā header whakautu o
https://api.shannon-ai.com: ka kawe teOnion-Locationi te wāhitau onion, ā, teX-I2P-Locationi te wāhitau I2P. Ka tīmata te wāhitau onion ki teshannon.
Ko ēhea ara e mahi ana
Ka whakautu ia ara /v1 i ngā wāhitau e whā katoa:
POST /v1/chat/completionsPOST /v1/responsesPOST /v1/messagesPOST /v1/messages/count_tokensPOST /v1/tokenizeGET /v1/models
Kāore he key e hiahiatia e te GET /v1/models, nō reira he whakamātau tere tērā mēnā e tae ana tō proxy ki te API.
Te mea ōrite me te mea rerekē
| Tūemi | Ōrite? | Taipitopito |
|---|---|---|
| Ngā ara, āpure tono, whakautu, hapa | Ōrite | He ōrite i ia wāhitau. Kāore he ara e rerekē te mahi mā te ingoa host. |
| API key | Ōrite | Ka mahi te key kotahi i ia wāhitau, hei Authorization: Bearer hei x-api-key rānei. Kāore ngā cookie e pānuitia i runga i te /v1. |
| Te toenga me ngā tepe | Ōrite | Te toenga ōrite me te tepe ōrite o te 120 tono ia meneti. Ka tatauria ngā mea e rua mō ia pūkete, kaua mō ia wāhitau. |
| Te rahi o te tono | Ōrite | Tae atu ki te 32 MiB mō ia tinana tono. |
| Kaupapa | Rerekē | https:// i runga i te tukutuku mārama me te whakaata. http:// i ngā wāhitau .onion me .b32.i2p, kei reira te whatunga ake e whakamuna ana i te hononga mai i tētahi pito ki tētahi. |
| Proxy | Rerekē | Kāore i runga i te tukutuku mārama. He SOCKS5 proxy mō Tor, he HTTP proxy mō I2P. Me whakatau te ingoa e te proxy, kaua e tō pūrere. |
| Tere | Rerekē | Ka tāpiri ngā whatunga e rua i te whakaroa ki ia paita. Ko te I2P te mea puhoi ake o rāua. |
Kua whakaahuatia te toenga me ngā tepe i tōna ake whārangi. Ngā tepe me te toenga
cURL mā Tor
Whakahaerehia tētahi kiritaki Tor i tō pūrere. Ka tuku ia i tētahi SOCKS5 proxy i te 127.0.0.1:9050. Ka tuku te --socks5-hostname i te ingoa .onion ki taua proxy.
# 1. Is the onion service reachable? No key needed.
curl --socks5-hostname 127.0.0.1:9050 http://shannonmd773o5vxz75byha5rkea7nzr3srotw46uwythq3pjl6y4cad.onion/v1/models
# 2. A streamed chat call. -N prints the stream as it arrives.
curl -N --socks5-hostname 127.0.0.1:9050 http://shannonmd773o5vxz75byha5rkea7nzr3srotw46uwythq3pjl6y4cad.onion/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "shannon-3",
"stream": true,
"messages": [{"role": "user", "content": "Hello over Tor"}]
}' cURL mā I2P
Whakahaerehia tētahi router I2P i tō pūrere. Ka tuku ia i tētahi HTTP proxy i te 127.0.0.1:4444, e whakaae ana ki te ingoa .b32.i2p pēnei i a ia.
# 1. Is the eepsite reachable? No key needed.
curl --proxy http://127.0.0.1:4444 http://acvnvkdea4xaczzjap7chysqqi4kkvp2eorfwkasindzmjpa47da.b32.i2p/v1/models
# 2. A streamed chat call.
curl -N --proxy http://127.0.0.1:4444 http://acvnvkdea4xaczzjap7chysqqi4kkvp2eorfwkasindzmjpa47da.b32.i2p/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "shannon-3",
"stream": true,
"messages": [{"role": "user", "content": "Hello over I2P"}]
}' Base URL SDK
E rua ngā huringa e hiahiatia ana e tētahi SDK: te base URL o te whatunga, me tētahi kiritaki HTTP ka haere mā te proxy. I Python ka whakaae ngā SDK ōkawa e rua ki tētahi kiritaki httpx. Mō tētahi SOCKS proxy whakaurua te httpx[socks].
# pip install openai "httpx[socks]"
import httpx
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="http://shannonmd773o5vxz75byha5rkea7nzr3srotw46uwythq3pjl6y4cad.onion/v1",
http_client=httpx.Client(proxy="socks5h://127.0.0.1:9050", timeout=600),
)
stream = client.chat.completions.create(
model="shannon-3",
messages=[{"role": "user", "content": "Hello over Tor"}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True) # pip install openai
import httpx
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="http://acvnvkdea4xaczzjap7chysqqi4kkvp2eorfwkasindzmjpa47da.b32.i2p/v1",
http_client=httpx.Client(proxy="http://127.0.0.1:4444", timeout=600),
)
stream = client.chat.completions.create(
model="shannon-3",
messages=[{"role": "user", "content": "Hello over I2P"}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True) # pip install anthropic "httpx[socks]"
import anthropic
import httpx
client = anthropic.Anthropic(
api_key="YOUR_API_KEY",
base_url="http://shannonmd773o5vxz75byha5rkea7nzr3srotw46uwythq3pjl6y4cad.onion",
http_client=httpx.Client(proxy="socks5h://127.0.0.1:9050", timeout=600),
)
with client.messages.stream(
model="shannon-1.6-lite",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello over Tor"}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True) Streaming me keep-alive i runga i ngā hononga puhoi
Ka mahi te streaming i ngā whatunga e rua. I a tētahi stream e tuwhera ana ā, kāore anō kia whai mea te model hei tuku, ka tuku te API i tētahi keep-alive, kia kore ai e rite te hononga ki te mea kua mate ki tētahi proxy, ki tō kiritaki rānei.
| Endpoint | Keep-alive i runga i tētahi stream tuwhera | Ka tukuna mō |
|---|---|---|
/v1/chat/completions | He rārangi kōrero (ka tīmata ki te :) ia 15 hēkona. | Ngā model katoa |
/v1/messages | He event: ping, he rārangi kōrero rānei, ia 15 hēkona. | Ngā model katoa |
/v1/responses | He rārangi kōrero ia 15 hēkona. | Ngā model open-weight hosted |
- Tukuna te
"stream": true. Ka tīmata te taenga mai o tētahi whakautu stream i te wā e tuhi ana te model, ā, ka whakaatu te keep-alive kei te mahia tonuhia te tono. Kāore tētahi whakautu kāore e stream e tuku i tētahi mea tae noa ki te rite o te whakautu katoa. - Hoatu ki te kiritaki tētahi timeout pānui roa. Ka whakamahi ngā tauira i te 600 hēkona. Ka taea e tētahi timeout iti iho i te 15 hēkona te whakamutu i tētahi stream i waenga i ngā keep-alive e rua.
- Tukuna tō kaipānui SSE kia whakarere i ngā rārangi kōrero me ngā kaupapa
ping. Ka mahia tēnei e ngā SDK kē. - Kaua e tuku anō i tētahi tono i te wā tonu ka hinga te hononga. Ka rere tētahi tono i tae ki te API ki tōna mutunga, ā, ka tatauria, ahakoa kua ngaro te hononga.
- Whakamātauria te ara ki te
GET /v1/modelsi te tuatahi. Kāore he key e hiahiatia, ā, ka whakahoki i tētahi rārangi JSON poto.
Ngā raruraru hononga
| Tohu | Te take me te whakatika |
|---|---|
Ka whakakāhoretia te hononga ki te 127.0.0.1:9050 ki te 127.0.0.1:4444 rānei | Kāore tētahi kiritaki Tor, router I2P rānei e rere ana i tō pūrere, e whakarongo ana rānei ki tētahi atu tauranga. Ka tuku a Tor Browser i tāna SOCKS proxy i te tauranga 9150. |
Could not resolve host mō te ingoa .onion | I whakamātau te kiritaki ki te whakatau i te ingoa mōna ake. Whakamahia te --socks5-hostname i cURL me te socks5h:// i tētahi URL proxy, kia whakatau te kiritaki Tor. |
| Ka whakautu te I2P proxy me tōna ake whārangi hapa | Kāore anō te router kia kite i te wāhitau. E hiahia ana tētahi router ki ētahi meneti i muri i tana tīmata. Whakamātauria anō. |
401 me Missing authentication | I tae mai te tono me te kore key. Tukuna te header ōrite ki tērā i runga i te tukutuku mārama. |
He ōrite ia hapa kē atu ki tērā i runga i te tukutuku mārama. Whakahaere hapa
Tō key me te kore JavaScript
He paetukutuku hoki tā Shannon me te kore JavaScript, ka taea te tae atu i runga i te tukutuku mārama, hei onion service, hei eepsite hoki. Ka whakaatu tōna whārangi /keys i tō API key, ā, ka tuku i a koe kia hurihia, nō reira ka taea e koe te tiki key me te kore wehe i a Tor, i a I2P rānei. encrypted.shannon-ai.com/keys
Kua rārangihia i konei ngā wāhitau o taua paetukutuku i ngā whatunga e toru: Whakawhiti whakamuna