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.ai 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:
bash
python --versionYou should see something like:
bash
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:
bash
python -m venv venvActivate it:
macOS / Linux
bash
source venv/bin/activateWindows
bash
venv\Scripts\activateStep 4 - Install Required Packages
Run:
bash
pip install openai python-dotenvWe use:
openai→ the official OpenAI Python SDK (works with Oxlo.ai out of the box)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:
bash
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:
python
import os
import openai
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
client = openai.OpenAI(
base_url="https://api.oxlo.ai/v1",
api_key=os.getenv("OXAPI_KEY")
)
response = client.chat.completions.create(
model="llama-3.2-3b",
messages=[
{"role": "user", "content": "Explain AI in one sentence."}
],
max_tokens=512
)
print(response.choices[0].message.content)✅ OpenAI Compatible: Oxlo.ai is fully compatible with the OpenAI SDK. Just set
base_url to https://api.oxlo.ai/v1 and use your Oxlo API key. Any code written for OpenAI works with Oxlo — no changes needed beyond these two fields.Step 7 - Run the Script
In your IDE terminal:
bash
python main.pyIf everything is set up correctly, you will see the model's response printed in your terminal. You are now successfully connected to Oxlo.ai using the OpenAI SDK.
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:
bash
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