What we are building
We are building a command-line language modeling workbench that turns rough outlines into clean prose, condenses long text into summaries, and polishes draft sentences for clarity. It is a practical starting point for developers and researchers who want to see how LLMs handle core text generation tasks without managing token budgets on every call. Because Oxlo.ai charges a flat rate per request, you can feed it multi-page outlines or lengthy source material without watching costs scale with context length.
What you will need
- Python 3.10 or newer
- The OpenAI SDK:
pip install openai - An Oxlo.ai API key from https://portal.oxlo.ai
Step 1: Initialize the Oxlo.ai client and verify connectivity
I always start by pinging the API with a trivial prompt to confirm authentication and routing. Create a file named lm_workbench.py and add the following.
from openai import OpenAI
client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")
SYSTEM_PROMPT = "You are a helpful assistant."
user_message = "Say 'Oxlo.ai connection OK'"
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_message},
],
)
print(response.choices[0].message.content)
Step 2: Define the system prompt
Our assistant needs to know it is a language modeling tool with three distinct modes. I keep the prompt in a constant so I can tweak behavior without hunting through functions.
SYSTEM_PROMPT = """You are a language modeling workbench. You support three tasks:
1. generate - Expand bullet points or an outline into fluent paragraphs.
2. summarize - Condense long input into a one-paragraph summary.
3. polish - Fix grammar, improve clarity, and maintain the original tone.
Follow the user's instruction exactly and return only the processed text."""
Step 3: Add a helper and implement the generate task
The generate task takes bullet points and returns flowing prose. I format the user message so the model knows which mode to use.
from openai import OpenAI
client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")
SYSTEM_PROMPT = """You are a language modeling workbench. You support three tasks:
1. generate - Expand bullet points or an outline into fluent paragraphs.
2. summarize - Condense long input into a one-paragraph summary.
3. polish - Fix grammar, improve clarity, and maintain the original tone.
Follow the user's instruction exactly and return only the processed text."""
def run_task(user_message: str) -> str:
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_message},
],
)
return response.choices[0].message.content.strip()
def generate(outline: str) -> str:
prompt = f"Task: generate\n\nOutline:\n{outline}"
return run_task(prompt)
if __name__ == "__main__":
sample = "- Intro to LLMs\n- Tokenization basics\n- Next-token prediction"
print(generate(sample))
Step 4: Implement the summarize task
For summarization, we pass a wall of text and ask for a tight paragraph. This is where Oxlo.ai's request-based pricing helps, because you can stuff in a long article and still pay the same flat cost.
from openai import OpenAI
client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")
SYSTEM_PROMPT = """You are a language modeling workbench. You support three tasks:
1. generate - Expand bullet points or an outline into fluent paragraphs.
2. summarize - Condense long input into a one-paragraph summary.
3. polish - Fix grammar, improve clarity, and maintain the original tone.
Follow the user's instruction exactly and return only the processed text."""
def run_task(user_message: str) -> str:
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_message},
],
)
return response.choices[0].message.content.strip()
def generate(outline: str) -> str:
prompt = f"Task: generate\n\nOutline:\n{outline}"
return run_task(prompt)
def summarize(text: str) -> str:
prompt = f"Task: summarize\n\nText:\n{text}"
return run_task(prompt)
if __name__ == "__main__":
long_text = (
"Large language models are neural networks trained on vast corpora. "
"They learn statistical patterns between words and use those patterns to predict the next token. "
"Modern architectures use transformers with self-attention, allowing them to model long-range dependencies. "
"This capability enables applications ranging from chatbots to code generation."
)
print(summarize(long_text))
Step 5: Implement the polish task
The polish task cleans up grammar and awkward phrasing while preserving meaning.
from openai import OpenAI
client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")
SYSTEM_PROMPT = """You are a language modeling workbench. You support three tasks:
1. generate - Expand bullet points or an outline into fluent paragraphs.
2. summarize - Condense long input into a one-paragraph summary.
3. polish - Fix grammar, improve clarity, and maintain the original tone.
Follow the user's instruction exactly and return only the processed text."""
def run_task(user_message: str) -> str:
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_message},
],
)
return response.choices[0].message.content.strip()
def generate(outline: str) -> str:
prompt = f"Task: generate\n\nOutline:\n{outline}"
return run_task(prompt)
def summarize(text: str) -> str:
prompt = f"Task: summarize\n\nText:\n{text}"
return run_task(prompt)
def polish(draft: str) -> str:
prompt = f"Task: polish\n\nDraft:\n{draft}"
return run_task(prompt)
if __name__ == "__main__":
rough = "The models is trained on alot of data and it can genrate text good."
print(polish(rough))
Step 6: Add a simple CLI router
Now wire the three tasks into a small argparse interface so you can call the script from the terminal with a mode flag and an input string.
import argparse
from openai import OpenAI
client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")
SYSTEM_PROMPT = """You are a language modeling workbench. You support three tasks:
1. generate - Expand bullet points or an outline into fluent paragraphs.
2. summarize - Condense long input into a one-paragraph summary.
3. polish - Fix grammar, improve clarity, and maintain the original tone.
Follow the user's instruction exactly and return only the processed text."""
def run_task(user_message: str) -> str:
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_message},
],
)
return response.choices[0].message.content.strip()
def generate(outline: str) -> str:
prompt = f"Task: generate\n\nOutline:\n{outline}"
return run_task(prompt)
def summarize(text: str) -> str:
prompt = f"Task: summarize\n\nText:\n{text}"
return run_task(prompt)
def polish(draft: str) -> str:
prompt = f"Task: polish\n\nDraft:\n{draft}"
return run_task(prompt)
def main():
parser = argparse.ArgumentParser(description="LLM Language Modeling Workbench")
parser.add_argument("task", choices=["generate", "summarize", "polish"])
parser.add_argument("input_text")
args = parser.parse_args()
if args.task == "generate":
result = generate(args.input_text)
elif args.task == "summarize":
result = summarize(args.input_text)
else:
result = polish(args.input_text)
print(result)
if __name__ == "__main__":
main()
Run it
Save the full script as lm_workbench.py and run the following commands.
$ python lm_workbench.py generate "- Benefits of request-based pricing\n- No cold starts\n- 45+ models"
Request-based pricing removes the guesswork from inference costs. Instead of counting tokens, you pay a flat fee per request, which makes budgeting predictable. Oxlo.ai serves requests without cold starts, so your first call is as fast as the hundredth. With more than 45 models available, you can pick the right architecture for each job without switching providers.
$ python lm_workbench.py summarize "Large language models are neural networks..."
Large language models use transformer architectures with self-attention to learn statistical word patterns from massive training corpora, enabling applications such as chatbots and code generation.
$ python lm_workbench.py polish "The models is trained on alot of data..."
The model is trained on a lot of data and can generate text well.
Wrap-up
You now have a working language modeling CLI backed by Oxlo.ai. To extend it, add file input so you can pipe entire documents into the summarize task, or switch the model to qwen-3-32b if you need multilingual generation. If you plan to run this in production, review Oxlo.ai pricing at https://oxlo.ai/pricing to choose a plan that matches your daily request volume.
Top comments (0)