Quickstart
Make your first Persly API call in under 5 minutes.
1. Get an API Key
Sign up at platform.persly.ai and create an API key from your dashboard. Your key will look like:
psl_test_a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4Keep your API key secret. Do not share it or expose it in client-side code.
2. Make Your First Request
curl https://api.persly.ai/v1/chat/completions \
-H "Authorization: Bearer $PERSLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "persly-chat-v1",
"messages": [
{
"role": "user",
"content": "What are the common side effects of metformin?"
}
]
}'import requests
response = requests.post(
"https://api.persly.ai/v1/chat/completions",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"model": "persly-chat-v1",
"messages": [
{
"role": "user",
"content": "What are the common side effects of metformin?",
}
],
},
)
data = response.json()
print(data["choices"][0]["message"]["content"])const response = await fetch("https://api.persly.ai/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "persly-chat-v1",
messages: [
{
role: "user",
content: "What are the common side effects of metformin?",
},
],
}),
});
const data = await response.json();
console.log(data.choices[0].message.content);3. Understand the Response
{
"id": "chatcmpl_a1b2c3d4e5f6a1b2c3d4e5f6",
"object": "chat.completion",
"created": 1709000000,
"model": "persly-chat-v1",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Common side effects of metformin include gastrointestinal symptoms such as nausea, diarrhea, and abdominal discomfort..."
},
"finish_reason": "stop"
}
],
"sources": [
{
"title": "Metformin - StatPearls",
"url": "https://www.ncbi.nlm.nih.gov/books/NBK518983/",
"relevance_score": 0.95
}
],
"usage": {
"request_count": 1
}
}Key fields:
choices[0].message.content— The AI responsesources— Medical references backing the responseusage.request_count— Billable request count (always 1)
Next Steps
- Authentication — API key formats and security best practices
- Models — Compare available models and pricing
- Streaming — Enable real-time response streaming
- Error Handling — Handle errors gracefully