Oxlo.ai

IDE Integration

This guide walks you step by step through creating a simple Python project in your IDE and connecting it to the OxAPI.

Note: No prior backend experience is required.

What You’ll Build

A small Python script that:

  • Connects to the Oxlo API
  • Sends a prompt
  • Prints the response

Step 1 - Install Python

If you don’t already have Python:

  1. Visit python.org
  2. Download Python 3.11 or later
  3. Install it

After installation, open a terminal and run:

python --version

You should see something like:

Python 3.x.x

Step 2 - Create a New Project in Your IDE

VS Code / Cursor

  1. Open VS Code
  2. Click File → Open Folder
  3. Create a new folder called OxAPI-script
  4. Open that folder

Step 3 - Create a Virtual Environment (Recommended)

In your IDE terminal, run:

python -m venv venv

Activate it:

macOS / Linux

source venv/bin/activate

Windows

venv\Scripts\activate

Step 4 - Install Required Packages

Run:

pip install requests python-dotenv

We use:

  • requests → to call the OxAPI
  • python-dotenv → to safely store your API key

Step 5 - Create a .env File

Inside your project folder, create a file named .env and add this line:

OXAPI_KEY=your_actual_api_key_here
⚠️ Security: Never commit this file to GitHub.

Step 6 - Create main.py

Create a new file called main.py and paste this code:

import os
import requests
from dotenv import load_dotenv

# Load environment variables
load_dotenv()

API_KEY = os.getenv("OXAPI_KEY")

url = "https://api.oxlo.ai/v1/chat/completions"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

data = {
    "model": "llama-3.2-3b-instruct",
    "messages": [
        {"role": "user", "content": "Explain AI in one sentence."}
    ]
}

response = requests.post(url, headers=headers, json=data)

print(response.json())

Step 7 - Run the Script

In your IDE terminal:

python main.py

If everything is set up correctly, you will see a JSON response containing the model output. You are now successfully connected to Oxlo.ai.

How It Works

  • Your API key is stored securely in .env
  • Python loads it into memory
  • The script sends an authenticated request
  • Oxlo.ai returns a structured JSON response

Common Errors

401 Unauthorized

  • Check your API key
  • Make sure there are no extra spaces
  • Confirm your .env file is saved

ModuleNotFoundError

Run:

pip install requests python-dotenv

Next Steps

You can now:

  • Modify the prompt
  • Change the model
  • Build a web app around this script
  • Convert this into a backend API