Quickstart
Get your first AI response in under 2 minutes.
Prerequisites
- An account at beginswithai.com
- An API key (generate one at api-keys after signup)
Free tier is available immediately—no credit card required.
Install a client library (optional)
We don't provide official SDKs yet, so we'll use Python's requests library or JavaScript's fetch.
No installation needed—fetch is built into Node.js 18+ and browsers.
Make your first request
Step 1: Submit a request
Python
import requests
import time
API_KEY = "your_api_key_here"
BASE_URL = "https://app.beginswithai.com/v1"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
payload = {
"model": "gpt-5.1",
"prompt": "Explain async APIs in one sentence"
}
response = requests.post(f"{BASE_URL}/ai", json=payload, headers=headers)
data = response.json()
request_id = data["request_id"]
print(f"Request queued: {request_id}")
JavaScript
const API_KEY = "your_api_key_here";
const BASE_URL = "https://app.beginswithai.com/v1";
const headers = {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
};
const payload = {
model: "gpt-5.1",
prompt: "Explain async APIs in one sentence"
};
const response = await fetch(`${BASE_URL}/ai`, {
method: "POST",
headers: headers,
body: JSON.stringify(payload)
});
const data = await response.json();
const requestId = data.request_id;
console.log(`Request queued: ${requestId}`);
You'll receive a response like:
Step 2: Poll for the result
Poll every 5 seconds until the status changes from queued to completed.
Python
while True:
poll_response = requests.get(
f"{BASE_URL}/ai",
params={"req_id": request_id},
headers=headers
)
result = poll_response.json()
if "response" in result:
print(f"Result: {result['response']}")
break
print("Still processing...")
time.sleep(5)
JavaScript
while (true) {
const pollResponse = await fetch(
`${BASE_URL}/ai?req_id=${requestId}`,
{ headers: headers }
);
const result = await pollResponse.json();
if (result.response) {
console.log(`Result: ${result.response}`);
break;
}
console.log("Still processing...");
await new Promise(resolve => setTimeout(resolve, 5000));
}
Complete example
Python
import requests
import time
API_KEY = "your_api_key_here"
BASE_URL = "https://app.beginswithai.com/v1"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
# Submit request
payload = {
"model": "gpt-5.1",
"prompt": "Explain async APIs in one sentence"
}
response = requests.post(f"{BASE_URL}/ai", json=payload, headers=headers)
data = response.json()
request_id = data["request_id"]
print(f"Request queued: {request_id}")
# Poll for result
while True:
poll_response = requests.get(
f"{BASE_URL}/ai",
params={"req_id": request_id},
headers=headers
)
result = poll_response.json()
if "response" in result:
print(f"\nResult: {result['response']}")
break
print("Still processing...")
time.sleep(5)
JavaScript
const API_KEY = "your_api_key_here";
const BASE_URL = "https://app.beginswithai.com/v1";
const headers = {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
};
async function main() {
// Submit request
const payload = {
model: "gpt-5.1",
prompt: "Explain async APIs in one sentence"
};
const response = await fetch(`${BASE_URL}/ai`, {
method: "POST",
headers: headers,
body: JSON.stringify(payload)
});
const data = await response.json();
const requestId = data.request_id;
console.log(`Request queued: ${requestId}`);
// Poll for result
while (true) {
const pollResponse = await fetch(
`${BASE_URL}/ai?req_id=${requestId}`,
{ headers: headers }
);
const result = await pollResponse.json();
if (result.response) {
console.log(`\nResult: ${result.response}`);
break;
}
console.log("Still processing...");
await new Promise(resolve => setTimeout(resolve, 5000));
}
}
main();
What just happened?
- You sent a request with a model and prompt
- The API queued it and returned a
request_id - You polled every 5 seconds until the result was ready
- You retrieved the final response
That's the entire async pattern.