Python
Norlen is OpenAI-compatible, so the official openai SDK in Python works by pointing base_url at Norlen.
pip install openaiConfiguration
Section titled “Configuration”from openai import OpenAI
client = OpenAI( base_url="https://api.norlen.io/v1", api_key="seu-token", # de preferência os.environ["NORLEN_API_KEY"])resp = client.chat.completions.create( model="qwen3.6-35b", messages=[{"role": "user", "content": "Hello, Norlen!"}],)print(resp.choices[0].message.content)Streaming
Section titled “Streaming”stream = client.chat.completions.create( model="qwen3.6-35b", messages=[{"role": "user", "content": "Count to five."}], stream=True,)for chunk in stream: print(chunk.choices[0].delta.content or "", end="", flush=True)Embeddings
Section titled “Embeddings”resp = client.embeddings.create( model="qwen3-embedding", input=["first text", "second text"],)print(resp.data[0].embedding[:5])Images
Section titled “Images”Image generation uses a different base URL (app.norlen.io/api/v1) and does not go through the SDK — use requests:
import base64, requests
r = requests.post( "https://app.norlen.io/api/v1/images/generations", headers={"Authorization": "Bearer SEU_TOKEN"}, json={"model": "qwen-image", "prompt": "A lighthouse at dawn", "size": "1024x1024"}, timeout=120,)open("imagem.png", "wb").write(base64.b64decode(r.json()["data"][0]["b64_json"]))