Skip to content
Try chatGet API key

Quickstart

Everything below talks to https://api.bayle.ai.

Copies this page's setup instructions, to paste into your coding agent.
Show the prompt
Help me set this up to use Bayle AI, an OpenAI-compatible API. Full guide: https://docs.bayle.ai/quickstart/

Goal: make my first Bayle chat completion from this project, using OpenAI's own SDK pointed at Bayle.

1. Check whether this project uses Python or Node (a pyproject.toml or requirements.txt, or a package.json). If it uses neither, ask me which to use. Install the SDK if it is missing: `pip install openai` or `npm install openai`.
2. Pick a model. List the text models (no key needed) and show me a short list:
   curl -s "https://api.bayle.ai/models?type=text" | jq -r '.data[].id'
   Let me choose, and use that id as MODEL_ID.
3. Create a small script (first_call.py or first_call.mjs) that builds the client from the environment and sends one chat completion.
   Python:
   import os
   from openai import OpenAI
   client = OpenAI(api_key=os.environ["BAYLE_API_KEY"], base_url="https://api.bayle.ai")
   completion = client.chat.completions.create(
       model="MODEL_ID",
       messages=[{"role": "user", "content": "In one sentence, what is an embedding?"}],
   )
   print(completion.choices[0].message.content)
   Node:
   import OpenAI from 'openai'
   const client = new OpenAI({ apiKey: process.env.BAYLE_API_KEY, baseURL: 'https://api.bayle.ai' })
   const completion = await client.chat.completions.create({
     model: 'MODEL_ID',
     messages: [{ role: 'user', content: 'In one sentence, what is an embedding?' }],
   })
   console.log(completion.choices[0].message.content)
4. Run the script and show me the answer.

Rules:
1. The base URL is https://api.bayle.ai exactly as written. Append no path to it.
2. Read the key from the BAYLE_API_KEY environment variable. Never write the key itself into a file you create, a command, a commit or the chat. Where the tool keeps the key in its own settings screen, tell me where to paste it. If BAYLE_API_KEY is not set, stop and ask me to create a key at https://chat.bayle.ai/developers and export it.
3. Take model ids only from GET https://api.bayle.ai/models (no key needed). Never guess one.
4. Finish with one real test request, show me the result and list the files you changed.
  1. GET /models needs no credential, which makes it the fastest way to check you can reach the API at all. It also tells you the model identifiers the rest of these examples need.

    Terminal window
    curl https://api.bayle.ai/models

    Narrow it to one class of model with ?type=text, ?type=image, ?type=embedding, and so on. See Models for the full list.

  2. Every other endpoint needs one. Keep it out of your source and read it from the environment.

    Terminal window
    export BAYLE_API_KEY="your-key"

    Don’t have a key yet? See Authentication.

  3. Pick a text model identifier from step 1 and send it with a list of messages.

    Terminal window
    curl https://api.bayle.ai/chat/completions \
    -H "Authorization: Bearer $BAYLE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "model": "MODEL_ID_FROM_STEP_1",
    "messages": [{"role": "user", "content": "In one sentence, what is an embedding?"}]
    }'

    The Python and JavaScript examples use OpenAI’s own SDK, pointed at Bayle. That is the intended way to use the API, and it is covered properly in OpenAI compatibility.

  • Text generation for streaming, function calling, and vision.
  • Images, where three behaviours differ from OpenAI’s API in ways worth reading before you debug them.
  • Video, which is a queue you poll rather than a single call.
  • Errors for every code the API can return.