
區(qū)塊鏈API推薦,快速開(kāi)發(fā)去中心化應(yīng)用
方式1:HTTP
$API_KEY替換為你的API 密鑰
curl --location 'https://api.lingyiwanwu.com/v1/chat/completions' \
--header 'Authorization: Bearer $API_KEY" \ //API 密鑰
--header 'Content-Type: application/json' \
--data '{
"temperature": 0.3,
"model": "yi-large-rag",
"stream": false,
"max_tokens": 3000,
"messages": [
{
"role": "user",
"content": "How is the weather in Los Angeles today?"
}
]
}'
響應(yīng)
{
"id": "cmpl-ea89ae83",
"object": "chat.completion",
"created": 5785971,
"model": "yi-large-rag",
"usage": {
"completion_tokens": 113,
"prompt_tokens": 896,
"total_tokens": 1009
},
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Today in Los Angeles, the weather is currently overcast with a temperature of 17°C. The forecast for the day indicates a high of 23°C and a low of 15°C, with sunny conditions expected at times. The humidity is currently at a comfortable level, and the chance of rain is 0% throughout the day. Winds are expected to be light, with an average speed of 3 to 4 mph. Overall, it looks like a pleasant day with a mix of sun and clouds."
},
"quote": [
{
"num": 1,
"url": "https://weather.com/weather/today/",
"title": "Los Angeles weather today"
},
{
"num": 2,
"url": "https://weather.com/weather/tenday/l/Los+Angeles+CA?canonicalCityId=84c64154109916077c8d3c2352410aaae5f6eeff682000e3a7470e38976128c2",
"title": "The Weather Channel: 10-Day Weather Forecast for Los Angeles, CA"
},
{
"num": 3,
"url": "https://www.accuweather.com/en/us/los+angeles/90012/weather-forecast/347625",
"title": "AccuWeather: Los Angeles, CA Weather Forecast"
},
{
"num": 4,
"url": "https://www.theweathernetwork.com/en/city/us/california/los+angeles/current",
"title": "The Weather Network: Los Angeles, CA"
},
{
"num": 5,
"url": "https://www.theweathernetwork.com/us/weather/california/los-angeles",
"title": "The Weather Network: Current Weather - Los Angeles"
},
{
"num": 6,
"url": "https://www.timeanddate.com/weather/usa/los-angeles",
"title": "Time and Date: Weather for Los Angeles, California, USA"
}
],
"finish_reason": "stop"
}
]
}
方式2:SDK
零一萬(wàn)物 API 在設(shè)計(jì)上完美兼容 OpenAI 的 Python SDK,只需要簡(jiǎn)單配置即可使用。
安裝 OpenAI SDK。請(qǐng)確保使用的 Python 版本至少為 3.7.1,OpenAI SDK 版本不低于 1.0.0。
1pip install openai
代碼示例
import openai
from openai import OpenAI
API_BASE = "https://api.lingyiwanwu.com/v1"
API_KEY = "your key"http:// 填入你的API 密鑰
client = OpenAI(
api_key=API_KEY,
base_url=API_BASE
)
completion = client.chat.completions.create(
model="yi-large",
messages=[{"role": "user", "content": "Hi, who are you?"}]
)
print(completion)
Q:如何找到零一萬(wàn)物API
A:冪簡(jiǎn)集成是國(guó)內(nèi)領(lǐng)先的API集成管理平臺(tái),專注于為開(kāi)發(fā)者提供全面、高效、易用的API集成解決方案。冪簡(jiǎn)API平臺(tái)可以通過(guò)以下兩種方式找到所需API:通過(guò)關(guān)鍵詞搜索API(例如,輸入’零一萬(wàn)物API‘這類品類詞,更容易找到結(jié)果)、或者從API hub分類頁(yè)進(jìn)入尋找。
Q:為什么要限速?
A:
Q:我的回答為什么被截?cái)嗔耍?/strong>
A:當(dāng)您在回復(fù)中看到 "finish_reason":"length"
,這意味著模型生成的內(nèi)容因超出 max_tokens 限制或達(dá)到了模型的最大上下文長(zhǎng)度。為了避免輸出被截?cái)啵ㄗh在調(diào)用 API 時(shí)適當(dāng)提高 max_tokens 的數(shù)值。
Q: 怎樣在 LangChain 和 LlamaIndex 中使用 Yi Model API?
A: 對(duì)于 LangChain,你需要從 langchain_openai 庫(kù)導(dǎo)入 ChatOpenAI,并設(shè)置相應(yīng)的 api_base、api_key 和 model 參數(shù)。對(duì)于 LlamaIndex,你需要從 llama_index.llms.openai_like和llama_index.core.llms 導(dǎo)入 OpenAILike 和 ChatMessage,并設(shè)置相應(yīng)的 api_base、api_key 和 model 參數(shù)。
Q:提供AI大模型 API的服務(wù)商除零一萬(wàn)物API,還有其他替代服務(wù)商也提供類似api服務(wù),例如:
A:360多模態(tài)大語(yǔ)言模型、語(yǔ)音大模型服務(wù)MiniMax-稀宇科技、通用大模型開(kāi)放平臺(tái)-華藏、訊飛星火認(rèn)知大模型
更多競(jìng)品可以在冪簡(jiǎn)集成開(kāi)放平臺(tái)中找到。
Q:零一萬(wàn)物API秘鑰還適用于哪些api?
A:List models、Create chat completion
本文總結(jié)了如何獲取零一萬(wàn)物API密鑰的分步指南,從注冊(cè)申請(qǐng)到成功獲取密鑰,為開(kāi)發(fā)者提供了明確的操作步驟。同時(shí),還概述了在獲取和使用零一萬(wàn)物API密鑰時(shí)可能需要注意的關(guān)鍵點(diǎn),如API的使用規(guī)定、密鑰的安全保管等,幫助開(kāi)發(fā)者順暢地將零一萬(wàn)物API集成到其應(yīng)用中。
對(duì)比大模型API的內(nèi)容創(chuàng)意新穎性、情感共鳴力、商業(yè)轉(zhuǎn)化潛力
一鍵對(duì)比試用API 限時(shí)免費(fèi)