Getting started
Quickstart
This guide takes you from an API key to a working conversation with your AI workers. Run the examples from your terminal or your server, never from a browser.
1. Get your API key
- In the NUWAY dashboard, open Settings › Integration › API Key.
- Copy your API key. It is shown in full only once, right after it is created. Store it somewhere safe, such as your server's environment variables or a secrets manager.
See Authentication and API keys for details.
2. Make the key available to your code
Put the key in an environment variable on the machine that sends the requests:
export NUWAY_API_KEY="your-api-key"3. Send your first message
curl https://ai.nuway.co/api/v1/external/chat \
-H "X-API-KEY: $NUWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "Hi, what do you offer?"}'// Node.js 18+. Uses top-level await: save as .mjs (or set "type": "module").
const res = await fetch("https://ai.nuway.co/api/v1/external/chat", {
method: "POST",
headers: {
"X-API-KEY": process.env.NUWAY_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({ message: "Hi, what do you offer?" }),
signal: AbortSignal.timeout(60_000),
});
const data = await res.json();
console.log(data.reply, data.session_id);import os
import requests
r = requests.post(
"https://ai.nuway.co/api/v1/external/chat",
headers={"X-API-KEY": os.environ["NUWAY_API_KEY"]},
json={"message": "Hi, what do you offer?"},
timeout=60,
)
r.raise_for_status()
data = r.json()
print(data["reply"], data["session_id"])A successful reply looks like this:
{
"session_id": "api_0a8a897f15f547a7839987037932a43b",
"reply": "Hi! We help businesses answer customer questions, book meetings and follow up with leads, 24/7.",
"agent": "support",
"answer_type": "ANSWER",
"ask_email": false,
"message_id": 36344,
"execution_time_ms": 2410
}Chat replies usually take 2–8 seconds. Use a client timeout of at least 60 seconds for chat.
4. Continue the conversation
Send the session_id from the reply with the next message. The AI remembers the conversation.
curl https://ai.nuway.co/api/v1/external/chat \
-H "X-API-KEY: $NUWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "Do you offer office tours?", "session_id": "api_0a8a897f15f547a7839987037932a43b"}'5. Read the conversation back
The conversation is stored like any other. Its chat_id is the session_id you received.
curl "https://ai.nuway.co/api/v1/external/conversations/api_0a8a897f15f547a7839987037932a43b" \
-H "X-API-KEY: $NUWAY_API_KEY"If something goes wrong
401: theX-API-KEYheader is missing, or the key is wrong, revoked or replaced.402: no chat credit is left. See Usage limits and billing.429: too many requests. Wait for the number of seconds inRetry-After.
See Errors and rate limits for every status code.
Next steps
- Chat reference: every request and response field.
- Code examples: a complete server-side chat relay.
- Integration scenarios: what teams build next.