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:
- Visit python.org
- Download Python 3.11 or later
- Install it
After installation, open a terminal and run:
python --versionYou should see something like:
Python 3.x.xStep 2 - Create a New Project in Your IDE
VS Code / Cursor
- Open VS Code
- Click File → Open Folder
- Create a new folder called
OxAPI-script - Open that folder
Step 3 - Create a Virtual Environment (Recommended)
In your IDE terminal, run:
python -m venv venvActivate it:
macOS / Linux
source venv/bin/activateWindows
venv\Scripts\activateStep 4 - Install Required Packages
Run:
pip install requests python-dotenvWe use:
requests→ to call the OxAPIpython-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.pyIf 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
.envfile is saved
ModuleNotFoundError
Run:
pip install requests python-dotenvNext Steps
You can now:
- Modify the prompt
- Change the model
- Build a web app around this script
- Convert this into a backend API