Developer quickstart

Make your first chat-completion request

Create an API key in your Edy dashboard, keep it on your server, and send it as a Bearer token. The API is OpenAI-compatible and streams Server-Sent Events.

  1. 01

    Create a key

    Open Dashboard → API keys and copy the key when it is created.

  2. 02

    Choose a model slug

    Copy a model slug from the Models documentation, or request https://edycode.vercel.app/api/v1/models.

  3. 03

    Call the endpoint

    POST messages to /api/v1/chat/completions and consume the streamed response.

cURL
curl https://edycode.vercel.app/api/v1/chat/completions \
  -H "Authorization: Bearer $EDY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL_SLUG",
    "messages": [
      {"role": "user", "content": "Explain async iterators in JavaScript."}
    ],
    "stream": true
  }'
JavaScript / Node.js
const response = await fetch("https://edycode.vercel.app/api/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.EDY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "YOUR_MODEL_SLUG",
    messages: [
      { role: "user", content: "Write a TypeScript debounce function." },
    ],
    stream: true,
  }),
});

if (!response.ok || !response.body) {
  throw new Error(await response.text());
}

const reader = response.body.getReader();
const decoder = new TextDecoder();

while (true) {
  const { value, done } = await reader.read();
  if (done) break;
  process.stdout.write(decoder.decode(value, { stream: true }));
}
Python
import os
import requests

response = requests.post(
    "https://edycode.vercel.app/api/v1/chat/completions",
    headers={
        "Authorization": f"Bearer {os.environ['EDY_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "model": "YOUR_MODEL_SLUG",
        "messages": [
            {"role": "user", "content": "Write a Python retry decorator."}
        ],
        "stream": True,
    },
    stream=True,
    timeout=120,
)
response.raise_for_status()

for line in response.iter_lines(decode_unicode=True):
    if line:
        print(line)

Request rules

  • • Put the model slug shown in this documentation in the request's model field.
  • • Never expose the API key in browser or client-side application code.
  • • A missing, invalid, or revoked key returns HTTP 401.
  • • Free models consume the account's RPM, TPM, and daily allowance without debiting the wallet.
  • • A top-up adds funds without enabling billing. Turn on Paid mode in the dashboard when you want to use premium models.
  • • Premium models return HTTP 403 in Free mode, or HTTP 402 when Paid mode is active but the balance is insufficient.
  • • Rate-limit responses use HTTP 429 and include a Retry-After header.
Create or manage API keys →