Integrations

OpenAI SDK

Call PromptsForLess from the OpenAI Python or TypeScript SDK by changing the base URL and key, with streaming examples.

The OpenAI SDK works with PromptsForLess once you set the base URL and key. Use chat.completions for text, streaming, tool calls and structured outputs.

Set up

Install the SDK with pip install openai for Python or pnpm add openai for TypeScript. Store your key from the dashboard as PFL_API_KEY in a secret manager or an ignored local environment file.

Send a request

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.promptsforless.com/v1",
    api_key=os.environ["PFL_API_KEY"],
)

response = client.chat.completions.create(
    model="deepseek-v4.1-flash",
    messages=[{"role": "user", "content": "Reply with a greeting."}],
)
print(response.choices[0].message.content)
print(response.usage)

Swap in any model ID from the catalog. Run this code on a server or your own machine; never ship the key in a browser bundle.

Stream a response

stream = client.chat.completions.create(
    model="deepseek-v4.1-flash",
    messages=[{"role": "user", "content": "Write a short greeting."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices:
        print(chunk.choices[0].delta.content or "", end="", flush=True)
print()

The Chat Completions reference describes request fields and streaming chunks.

Add tools and structured output

Pass tools for tool calls and response_format for structured outputs, exactly as you would with OpenAI. Pick a model that supports the feature; image input, for example, needs a vision model.

For authentication and connection errors, see the quickstart troubleshooting table. Compare model IDs and prices in the catalog.

On this page