Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 4 min read

Building a Language Model with LLM: A Beginner's Guide

We are building a multilingual writing assistant that rewrites rough drafts, fixes grammar, and explains its changes. I run it on Oxlo.ai because the flat per-request pricing means a 2,000-word document costs the same as

We are building a multilingual writing assistant that rewrites rough drafts, fixes grammar, and explains its changes. I run it on Oxlo.ai because the flat per-request pricing means a 2,000-word document costs the same as a tweet. If you are new to LLMs, this is the fastest way to ship a useful language tool.

What you'll need

Step 1: Configure the Oxlo.ai client

Create a file named assistant.py. Import the SDK and point it at Oxlo.ai. I use qwen-3-32b in this project because it handles mixed-language input reliably.

from openai import OpenAI

client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")

print("Oxlo.ai client ready.")

Step 2: Define the system prompt

The system prompt is the only logic this app needs. I force JSON output so the response is machine readable without regex hacks.

SYSTEM_PROMPT = """You are a professional writing assistant. When the user provides a draft:

1. Rewrite it for clarity, correct grammar, and appropriate tone.
2. If the draft is not in English, translate it to polished English unless the user asks otherwise.
3. Provide a brief list of the top 3 changes you made.
4. Return ONLY a JSON object with this exact structure:
{
  "rewritten": "the improved text",
  "changes": ["change 1", "change 2", "change 3"]
}

Do not add markdown code fences around the JSON."""

Step 3: Build the draft processor

This function sends the draft to Oxlo.ai and parses the JSON response. Enabling json_object mode makes the model return valid JSON.

import json
from openai import OpenAI

client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")

SYSTEM_PROMPT = """You are a professional writing assistant. When the user provides a draft:

1. Rewrite it for clarity, correct grammar, and appropriate tone.
2. If the draft is not in English, translate it to polished English unless the user asks otherwise.
3. Provide a brief list of the top 3 changes you made.
4. Return ONLY a JSON object with this exact structure:
{
  "rewritten": "the improved text",
  "changes": ["change 1", "change 2", "change 3"]
}

Do not add markdown code fences around the JSON."""

def improve_draft(draft: str) -> dict:
    response = client.chat.completions.create(
        model="qwen-3-32b",
        messages=[
            {"role": "system", "content": SYSTEM_PROMPT},
            {"role": "user", "content": draft},
        ],
        response_format={"type": "json_object"},
    )
    raw = response.choices[0].message.content
    return json.loads(raw)

# Quick smoke test
sample = "i didnt recieve the package yet, its been 2 week and im getting angry!!"
print(improve_draft(sample))

Run it

Save the full script below as assistant.py and run python assistant.py. The loop processes three drafts and prints the results.

import json
from openai import OpenAI

client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")

SYSTEM_PROMPT = """You are a professional writing assistant. When the user provides a draft:

1. Rewrite it for clarity, correct grammar, and appropriate tone.
2. If the draft is not in English, translate it to polished English unless the user asks otherwise.
3. Provide a brief list of the top 3 changes you made.
4. Return ONLY a JSON object with this exact structure:
{
  "rewritten": "the improved text",
  "changes": ["change 1", "change 2", "change 3"]
}

Do not add markdown code fences around the JSON."""

def improve_draft(draft: str) -> dict:
    response = client.chat.completions.create(
        model="qwen-3-32b",
        messages=[
            {"role": "system", "content": SYSTEM_PROMPT},
            {"role": "user", "content": draft},
        ],
        response_format={"type": "json_object"},
    )
    raw = response.choices[0].message.content
    return json.loads(raw)

drafts = [
    "i didnt recieve the package yet, its been 2 week and im getting angry!!",
    "Estoy muy contento con el producto, pero el envΓ­o fue demasiado lento.",
    "The report is due ASAP, please review the attached file and give feedback.",
]

for d in drafts:
    result = improve_draft(d)
    print("Original:", d)
    print("Rewritten:", result["rewritten"])
    print("Changes:", result["changes"])
    print("-" * 40)

Expected output:

Original: i didnt recieve the package yet, its been 2 week and im getting angry!!
Rewritten: I have not received the package yet. It has been two weeks, and I am becoming concerned.
Changes: ["Fixed spelling of 'receive'", "Expanded contractions for professional tone", "Replaced 'angry' with 'concerned' to soften tone"]
----------------------------------------
Original: Estoy muy contento con el producto, pero el envΓ­o fue demasiado lento.
Rewritten: I am very pleased with the product, but the delivery was far too slow.
Changes: ["Translated from Spanish to English", "Maintained positive opening while clarifying complaint", "Used 'delivery' instead of 'shipment' for natural English"]
----------------------------------------
Original: The report is due ASAP, please review the attached file and give feedback.
Rewritten: The report is due as soon as possible. Please review the attached file and provide your feedback.
Changes: ["Expanded 'ASAP' for clarity", "Replaced 'give' with 'provide' for formality", "Added 'your' for polite directness"]

Wrap-up

That is the entire pipeline. Two concrete next steps: add a FastAPI endpoint so other services can POST drafts to it, or swap the model to llama-3.3-70b if your users write primarily in English and you want the strongest general reasoning. Both changes take about ten minutes because the client is fully OpenAI compatible.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.