డెవలపర్లు
API quickstart
OpenAI‑అనుకూల Cosvexa API: కీ సృష్టించడం, మీ మొదటి అభ్యర్థన, స్ట్రీమింగ్, టూల్ కాలింగ్ మరియు Auto రూటింగ్.
Cosvexa API చాట్ కంప్లీషన్లు మరియు మోడల్ జాబితా కోసం OpenAI‑అనుకూలమైనది: OpenAI SDK లో బేస్ URL మార్చండి, అంతే. Pro, Team మరియు Enterprise లో కీ మీ ప్లాన్లో ఉన్న ప్రతి మోడల్ను వాడుతుంది; Free లో రోజుకు మీ 50 ఉచిత ప్రశ్నల పరిధిలో Cosvexa-1 ను వాడుతుంది.
https://cosvexa.ai/api/v1API కీ
- 1
డెవలపర్ కన్సోల్ తెరవండి
Developer లోని Keys ట్యాబ్కు వెళ్లండి. మీరు వర్క్స్పేస్ అడ్మిన్ లేదా ఓనర్ అయి ఉండాలి.
- 2
కీ సృష్టించండి
కీలు
cvx_తో ప్రారంభమవుతాయి, ఒక్కసారి మాత్రమే చూపబడతాయి; మీ కీని వెంటనే సురక్షితమైన చోట భద్రపరచండి. మేము హాష్ను మాత్రమే ఉంచుతాము. - 3
దాన్ని ఉపయోగించండి
ప్రతి అభ్యర్థనతో
Authorization: Bearer cvx_...పంపండి. అదే పేజీలో కీని రద్దు చేయవచ్చు.
మీ కీని ఎప్పుడూ బ్రౌజర్ కోడ్లో లేదా పబ్లిక్ రిపోజిటరీలో ఉంచవద్దు. API క్రాస్‑ఆరిజిన్ బ్రౌజర్ కాల్లను (CORS) అనుమతించదు; మీ సర్వర్ నుండి కాల్ చేయండి.
మొదటి అభ్యర్థన
curl https://cosvexa.ai/api/v1/chat/completions \
-H "Authorization: Bearer $COSVEXA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"cosvexa-auto","messages":[{"role":"user","content":"Hello"}]}'OpenAI SDK తో (Python)
from openai import OpenAI
client = OpenAI(base_url="https://cosvexa.ai/api/v1", api_key="cvx_...")
res = client.chat.completions.create(
model="cosvexa-auto",
messages=[{"role": "user", "content": "Hello"}],
)
print(res.choices[0].message.content)OpenAI SDK తో (JavaScript)
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://cosvexa.ai/api/v1", apiKey: process.env.COSVEXA_API_KEY });
const res = await client.chat.completions.create({
model: "claude-sonnet-5-5",
messages: [{ role: "user", content: "Hello" }],
});
console.log(res.choices[0].message.content);మోడల్ ఎంపిక
cosvexa-auto(లేదాauto): Cosvexa టాస్క్ను వర్గీకరించి తగిన మోడల్ను ఎంచుకుంటుంది. రెస్పాన్స్లోనిmodelఫీల్డ్ ఏ మోడల్ సమాధానం ఇచ్చిందో చూపిస్తుంది.- నిర్దిష్ట మోడల్ కోసం, `GET /models` నుండి ఒక
idఉపయోగించండి (ఉదా.claude-opus-5-5,gpt-6-astra). నిర్దిష్ట మోడల్ ఎప్పుడూ నిశ్శబ్దంగా మార్చబడదు. - Council మరియు Project మోడ్లు API ద్వారా అందుబాటులో లేవు.
స్ట్రీమింగ్
curl -N https://cosvexa.ai/api/v1/chat/completions \
-H "Authorization: Bearer $COSVEXA_API_KEY" -H "Content-Type: application/json" \
-d '{"model":"cosvexa-auto","stream":true,"stream_options":{"include_usage":true},
"messages":[{"role":"user","content":"Write a haiku"}]}'రెస్పాన్స్ text/event-stream: ప్రతి చంక్ ఒక data: {...} లైన్, స్ట్రీమ్ data: [DONE] తో ముగుస్తుంది. include_usage తో, చివరి చంక్లో టోకెన్ వినియోగం మరియు ఛార్జ్ చేసిన క్రెడిట్లు ఉంటాయి; అది లేకుండా స్ట్రీమ్ క్రెడిట్లను తెలియజేయదు. స్ట్రీమ్ మధ్యలో ఎర్రర్ జరిగితే, ఎర్రర్ status మరియు code తో data: {"error":{...}} పంపబడుతుంది, తర్వాత [DONE]; API రిఫరెన్స్ చూడండి.
టూల్ కాలింగ్ (ఫంక్షన్ కాలింగ్)
{
"model": "cosvexa-auto",
"messages": [{ "role": "user", "content": "What's the weather in Istanbul?" }],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"parameters": { "type": "object", "properties": { "city": { "type": "string" } }, "required": ["city"] }
}
}],
"tool_choice": "auto"
}మోడల్కు టూల్ కావాలనుకున్నప్పుడు, finish_reason విలువ tool_calls అవుతుంది, message.tool_calls తిరిగి వస్తుంది. టూల్ను మీరే నడిపి, ఫలితాన్ని role: "tool" మరియు tool_call_id తో తిరిగి పంపండి. Auto లో, టూల్స్ ఉన్న అభ్యర్థనలు కోడ్ టాస్క్లుగా రూట్ చేయబడతాయి; టూల్ సపోర్ట్ లేని మోడల్ను ఎంచుకుంటే 400 వస్తుంది.
ఇమేజ్ ఇన్పుట్
మెసేజ్ కంటెంట్లో {"type":"image_url","image_url":{"url":"data:image/png;base64,..."}} ఉపయోగించండి. base64 data: URL లు మాత్రమే అంగీకరించబడతాయి (PNG, JPEG, WebP, GIF); భద్రత కోసం రిమోట్ URL లు తిరస్కరించబడతాయి.
అన్ని ఎండ్పాయింట్లు, ఎర్రర్ కోడ్లు మరియు పరిమితులు: API రిఫరెన్స్.