Blog

Hetzner Experiments: Testing Free Inference with Qwen (Long Context, Vision, Code)

Hetzner Experiments: Testing Free Inference with Qwen (Long Context, Vision, Code)

Hetzner has a new platform called Experiments, and right now they’re giving away LLM inference on it for open-weight models like Qwen.

In this post, I’ll break down how to run inference with OpenAI-compatible REST APIs (like the one provided by Hetzner), and test out Qwen 3.6:

  • a basic SDK request
  • batch support ticket classification
  • 150k long-context needle in a haystack
  • multimodal vision
  • agentic workflows with OpenCode

My video above is sponsored by Hetzner. They asked me to take it for a spin on ZazenCodes and talk about my experience using it. If you want to build on their stuff, the code zazencodes20 gets you $20 to start with, good until the end of 2026. Sign up here.

Watch: on YouTube · Code: on GitHub

What Hetzner Experiments Is

Watch Video

As the name suggests, Hetzner’s Experiments Platform is an experimental playground. Currently they are providing open-weight model endpoints hosted on their own GPUs, and right now it’s completely free to try out. They want people to use it and tell them what they think.

The star of the platform today is Qwen. At time of writing, the exact model is Qwen/Qwen3.6-35B-A3B-FP8, 35 billion parameters, fast and accurate thanks to its mixture of experts architecture. This is what I’m using for the demos below.

The platform implements standard OpenAI REST APIs. You point at a URL like this:

https://inference.hetzner.com/api/v1

This endpoint is “OpenAI REST API compatible”. I’ll show you what that means, and how the OpenAI SDK fits on top of it.

Demos

Here’s what I’m testing:

  1. A basic API request for inference
    Understand the OpenAI SDK
  2. A real use case: batch ticket analysis.
    Batch classification is the classic AI engineering job, and exactly the kind of thing you’d want an open-weights model for.
  3. A needle in the haystack test for long context.
    I have a bit of a different spin on this one, seeing how well the model can do missing-context reconstruction.
  4. Vision tests.
    I’ve got a fun demo here using a free random image API.
  5. A coding agent.
    I’m plugging this into OpenCode to see how Qwen does on a real agentic coding task.

Part 1: Basic SDK Request

Watch Video

Environment Setup

If you’re following along, make a new folder for your project and create a virtual environment with the OpenAI SDK installed:

mkdir hetzner-inference-demo
cd hetzner-inference-demo

# Setup virtual environment
python3 -m venv .venv
.venv/bin/pip install openai
source .venv/bin/activate

Once it’s activated, which python will show you the Python inside the virtual environment.

Next you should spin up a Jupyter Notebook.

  1. Open VS Code and create a new file called demo.ipynb.
  2. Select the virtual environment you just made as the kernel. If it hasn’t happened automatically, VS Code will prompt you for it.
  3. Add a first code cell and import time.

When I did this, VS Code immediately prompted me to install the ipykernel package, which is what lets the notebook run inside the new virtual environment. Confirm you want to install this, then continue with the demo below.

Your First Request

Now the library we actually came for:

from openai import OpenAI

client = OpenAI(
    base_url="https://inference.hetzner.com/api/v1",
    api_key="qNFpw3IxhiKjg4CsjHf_5GJHOpVKncZ5",
)

OpenAI is an HTTP client, and here it points at the Hetzner base URL instead of OpenAI’s. For the key, I went into the Hetzner experiments platform console, clicked Inference, then Create API Token, and pasted it in.

Next, the request:

response = client.chat.completions.create(
    model="Qwen/Qwen3.6-35B-A3B-FP8",
    messages=[{"role": "user", "content": "what is Einstein famous for?"}],
)

What comes back is a big chat completion object. You can then parse out the
text as follows:

print(response.choices[0].message.content)

For me, this printed the following text:

Albert Einstein is most famous for revolutionizing modern physics through his
theory of relativity, which comes in two parts:

- Special Relativity (1905): Introduced the idea that the laws of physics are
  the same for all non-accelerating observers and that the speed of light is
  constant. From this came his iconic equation E=mc², showing that mass and
  energy are interchangeable.
- General Relativity (1915): Redescribed gravity not as a force, but as the
  curvature of spacetime caused by mass and energy. It successfully predicted
  phenomena like the bending of light by gravity, black holes, and
  gravitational waves.

He also won the 1921 Nobel Prize in Physics for his explanation of the
photoelectric effect, which demonstrated that light behaves as discrete
packets of...

The response object itself looks something like this:

ChatCompletion(
    id='chatcmpl-0bc347f3-6455-415d-b581-76627bff42b6',
    choices=[
        Choice(
            finish_reason='stop',
            index=0,
            message=ChatCompletionMessage(
                content='...',
                role='assistant',
                reasoning='...',
            ),
        )
    ],
    created=1787107743,
    model='Qwen/Qwen3.6-35B-A3B-FP8',
    object='chat.completion',
    usage=CompletionUsage(
        completion_tokens=2356,
        prompt_tokens=179,
        total_tokens=2535,
    ),
)

Note the reasoning field: Qwen and other “thinking” models stream their thinking back separately from the final answer. These reasoning tokens count as output tokens, and count towards your max_tokens (as discussed below).

Script Version

Next let’s talk through a more realistic script for doing inference: 1_basic.py, and it does one thing differently right away: it doesn’t embed the API key in the application. It reads os.environ instead, so before running it I set the key in the shell:

export HETZNER_VLLM_API_KEY=<your-key>

The rest of the script instantiates the client the same way, defines a model and a prompt, starts a timer with time.perf_counter, and prints the response:

import os
import time

from openai import OpenAI

client = OpenAI(
    base_url="https://inference.hetzner.com/api/v1",
    api_key=os.environ.get("HETZNER_VLLM_API_KEY"),
)

model = "Qwen/Qwen3.6-35B-A3B-FP8"
prompt = "Explain what a reverse proxy does in three concise bullet points."

start = time.perf_counter()
response = client.chat.completions.create(
    model=model,
    messages=[{"role": "user", "content": prompt}],
    max_tokens=500,
)
elapsed = time.perf_counter() - start

print(response.choices[0].message.content)
print(f"Runtime: {round(elapsed, 2)} seconds")
print(f"Usage: {response.usage}")

Round trip was about 20 seconds.

When I ran this, the answer cut off mid-sentence at “never directly connect your”. That was due to having set max_tokens=500.

Part 2: Support Ticket Batch

Watch Video

Next up is a batch job: 25 realistic support tickets pushed through the inference API.

I invented them around a doggy daycare, and they live in data/tickets.json. Subjects like “multi-pet sibling discount” and “tips for my border collie with endless energy”.

For this we’ll need to first load the tickets, which are in a JSON file:

import json
from pathlib import Path

tickets = Path("data/tickets.json").read_text()
tickets = json.loads(tickets)

read_text gives you a string. json.loads gives you the actual parsed object.

Then the loop. Iterate, log which ticket is in flight, collect the responses, and record how long each one took:

responses = []
for number, ticket in enumerate(tickets):
    print(f"processing ticket number {number}")
    start_time = time.time()
    response = client.chat.completions.create(
        model="Qwen/Qwen3.6-35B-A3B-FP8",
        messages=[
            {"role": "system", "content": "you work for a doggy daycare, always respond really angry"},
            {"role": "user", "content": f"{ticket}"},
        ],
    )
    fetch_time = time.time() - start_time
    responses.append({"ticket": ticket, "response": response, "fetch_time": fetch_time})

Note the system prompt. Important to get the tone right for this one. LOL.

Now let’s look at a more sophisticated version of this loop, in 2_tickets.py. Notice the prompt to classify this doggy daycare support request, return valid JSON only with the following schema. That’s how you get Qwen to hand you something structured that you can process later.

prompt = f"""Classify this doggy daycare support request.

Return valid JSON ONLY with the following schema:
{{
  "category": "billing" | "technical" | "account" | "feature_request" | "urgent_security",
  "priority": "low" | "medium" | "high" | "critical",
  "summary": "one sentence summary",
  "recommended_action": "recommended action for support agent",
  "customer_response": "polite draft response to the customer"
}}

Ticket #{ticket.get("id", idx)}:
{ticket["subject"]}:
{ticket["text"]}
"""

response = client.chat.completions.create(
    model=model,
    messages=[{"role": "user", "content": prompt}],
    max_tokens=3000,
)
content = response.choices[0].message.content.strip()

# Clean potential markdown wrapping
clean_content = content
if clean_content.startswith("```json"):
    clean_content = clean_content[7:]
if clean_content.startswith("```"):
    clean_content = clean_content[3:]
if clean_content.endswith("```"):
    clean_content = clean_content[:-3]
clean_content = clean_content.strip()

try:
    parsed_json = json.loads(clean_content)
except json.JSONDecodeError:
    parsed_json = None

It passes the ticket number and the ticket text, strips any markdown fencing the model wraps around the JSON, and puts a try/except around the parse in case the model ignores you. I also bumped the max_tokens to 3000 to handle more thinking and longer result outputs.

This is a great example of basic AI engineering work.

Part 3: 150K Needle & Completion

Watch Video

Time to push the context size and see how Qwen performs.

I copied the demo notebook, stripped it down to the client setup, and loaded the full text of Twenty Thousand Leagues Under the Sea from Project Gutenberg. I’d asked a coding agent to help build this demo earlier and it had already pulled the whole book down into data/book.txt.

But let’s say it hadn’t. The old school way is requests, which isn’t in the standard library, so pip install requests inside the virtual environment first:

import requests

page = requests.get(url)
page.text

That gives you the book, wrapped in HTML. Next step would be parsing it out with something like BeautifulSoup, and that’s a pain (trust me; I’ve likely spent cumulative days of time doing this over my years working in digital marketing), and clearly out of scope for a demo where the file is already sitting on disk. So:

from pathlib import Path

book = Path("data/book.txt").read_text()

Now the test. The usual needle in a haystack setup hides a fact somewhere in a huge context and asks the model to find it. I wanted something harder. I went to The Black River chapter in part one, picked a paragraph at line 3073, and cut it off partway through, keeping the original line in a note so I’d have something to compare against.

The prompt: there is a missing paragraph cut off partially through, identify that paragraph in this book and complete it as if it was written in the original manuscript, then output the completed chapter. I wrapped the whole book in <book></book> tags, since a bit of XML formatting tends to help. Handhold the model as much as you can.

import time

start = time.time()
response = client.chat.completions.create(
    model=model,
    messages=[
        {
            "role": "user",
            "content": (
                "There is a missing paragraph in the book below. One of these "
                "paragraphs has been cut off partially through mid sentence. "
                "I need you to identify that paragraph in this "
                "book and complete that paragraph as if it was "
                "written in the original manuscript. Output the chapter "
                "of the paragraph and the completed version that you generate.\n"
                f"<book>{book}</book>"
            ),
        }
    ],
)
elapsed_seconds = time.time() - start
print(response.choices[0].message.content)

While it ran I wanted a token count.

I spun up a coding agent (Google Antigravity) and it whipped up a tiktoken script. The result was around 150,000 tokens of context in the entire book. Perfect for testing this model.

The result came back in three and a half minutes, and it actually did find the right paragraph.

It punted on the actual reconstruction task a bit, giving me “then disappeared beneath the waters” instead of the more verbose original line. Still, it located the needle. Not bad, Qwen.

There’s also a pre-written script for this one at 3_long_context.py if you want the non-notebook version.

Part 4: Multimodal Vision

Watch Video

On to the vision example, 4_vision.py. I love a good vision example, and this one I’d been looking forward to.

There’s an API at picsum.photos/seed/{seed} that hands you a random image based on whatever seed you give it. Paste it in the browser with one number, you get a picture. Change the number, you get a totally different picture. I think you see where I’m going with this: make a random request, feed the image to Qwen/Qwen3.6-35B-A3B-FP8, and get it to tell me what it’s looking at.

The seed gets inserted with .format, then it’s a requests.get. The content that comes back is a binary object, and I’m assuming everything I get back is an image. Base64 encode those bytes, wrap them in an image data URI, and that URI is what gets attached when you call the chat completions endpoint.

import requests

target_url = "https://picsum.photos/seed/{seed}/1024/768"
page = requests.get(target_url.format(seed=21381273))

import base64

image_bytes = page.content
image_data_uri = "data:image/jpeg;base64," + base64.b64encode(image_bytes).decode()

Here’s what the inference request looks like:

prompt = "What is in this photo?"

response = client.chat.completions.create(
    model=model,
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": prompt},
                {"type": "image_url", "image_url": {"url": image_data_uri}},
            ],
        }
    ],
    max_tokens=600,
)

I ran it and printed the content. None.

So I printed the whole response instead, and the reasoning field was very much alive. The user wants a detailed description of the provided photo. Further down: Texture and material. It’s definitely wood. I can see grain. The thinking was happening. There just wasn’t an answer at the end of it.

Here’s why. I’d set max_tokens to 600, and reasoning tokens count against that budget. The model spent the whole allowance thinking about wood grain and never got to write the response.

Fix: tell it to keep the thinking short (optional), and give it more room to output (this is the real fix):

I set max_tokens=6000 and ran with:

prompt = "What is in this photo? Describe it in detail. Keep the thinking short."

And boom. Here’s my output:

The photo displays a closeup view of a rustic wooden surface.

And it went further, calling out distinct imprints below the dark patch on the lower plank. I went and looked, and yeah, there are footprints there.

It turns out Qwen is a really great vision model.

Part 5: Autonomous Coding Agent

Watch Video

Last thing I wanted to do was plug Qwen 3.6 into OpenCode through Hetzner’s inference API.

On Hetzner’s site, under the experiments platform overview, there’s an OpenCode community tutorial. It’s got a whole section on creating a sandbox wrapper, which I think is a really interesting part of the demo. It’s outside the scope of this post, but go find it and consider working through it.

I’m focusing on the basics. Install OpenCode, then configure it, which means an opencode.json file. That file has to sit in the folder you launch OpenCode from. That’s the whole trick. OpenCode finds it on startup and that’s why the model shows up in the corner.

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "hetzner": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Hetzner",
      "options": {
        "baseURL": "https://inference.hetzner.com/api/v1",
        "apiKey": "{env:HETZNER_VLLM_API_KEY}"
      },
      "models": {
        "Qwen/Qwen3.6-35B-A3B-FP8": {
          "name": "Qwen3.6-35B-A3B-FP8"
        }
      }
    }
  },
  "model": "hetzner/Qwen/Qwen3.6-35B-A3B-FP8"
}

The schema field is just there to explain what you’re looking at. It runs through an npm library, the options block points at the Hetzner endpoint, and the API key gets pulled from HETZNER_VLLM_API_KEY at runtime. That variable has to be set in your session. No keys baked into the config.

So now I have a coding agent, sitting in my agent-demo/ folder with docs and src in it. First test: look in src, find any bugs in this codebase, only real bugs, not potential features.

It read three files and got it. Line 22, the bulk discount threshold being checked against total GB instead of primary GB. That’s the actual bug. Figured it out right away.

# storage_pricing.py
DISCOUNT_THRESHOLD_GB = 5000.0

# Line 22: should check account.total_gb, not account.primary_gb
if account.primary_gb >= DISCOUNT_THRESHOLD_GB:
    subtotal *= (1.0 - BULK_DISCOUNT_PERCENT)

You might be thinking it cheated off the README. It didn’t. The README is a directory above where the agent was running, and it only read those three files.

It was also fast. Fast enough to actually be usable. I did not expect that.

Second test, the agentic one: copy the project you’re in now, same folder name, over to zazencodes-season-3/src, and exclude any big data files.

It cooked up the directory, ran rsync with the right exclusions, got the folder name right. Then it noticed the old files were still around and ran an rm -rf without even asking me. Probably an OpenCode thing rather than the model’s fault, though it’s weird that it asks permission on other stuff.

Then I looked at git status. It deleted my whole repository. LOL.

So I threw away those changes and brought all my files back:

git fetch origin
git reset --hard

After that failure I can confidently say I would not recommend Qwen 3.6 for agentic coding tasks. The speed through Hetzner’s free API was genuinely usable, which I was surprised about, but the model just isn’t smart enough for me. I’m straight up never going to reach for it here. It’s far better suited for the types of tasks that we discussed leading up to this one.

Integration Architecture

Watch Video

I wanted to wrap this post up with a discussion of the integration architecture for the API.

We have been writing Python applications, and inside these, we’re using the OpenAI Python SDK. That’s the client object. It’s doing a lot of the HTTP work you’d otherwise write yourself: building the request, serializing the JSON, handling authentication with your HETZNER_VLLM_API_KEY, and parsing the response back into a shape you can count on. Streaming and errors too. This is the standard everyone settled on for making API requests to LLMs, which is exactly why pointing it at a different base URL works at all.

That request goes out to https://inference.hetzner.com/api/v1. What you hit first is a load balancer, a single server endpoint that routes you onward into the actual infrastructure doing the inference. That’s where the heavy lifting happens, on GPUs running Qwen/Qwen3.6-35B-A3B-FP8. When it’s done, the response comes back up to your Python application.

┌──────────────────────────────────────────────┐
│       Your Python App / Coding Agent         │
│                                              │
│  client.chat.completions.create(...)         │
└──────────────────────┬───────────────────────┘
                       │
                       │ Python method call
                       ▼
┌──────────────────────────────────────────────┐
│              OpenAI Python SDK               │
│                                              │
│ • Builds request                             │
│ • Serializes JSON                            │
│ • Handles auth (HETZNER_VLLM_API_KEY)        │
│ • Parses responses                           │
│ • Handles streaming / errors                 │
└──────────────────────┬───────────────────────┘
                       │
                       │ HTTPS request using
                       │ OpenAI-compatible API format
                       ▼
┌──────────────────────────────────────────────┐
│           Hetzner Experiments API            │
│                                              │
│ https://inference.hetzner.com/api/v1         │
│                                              │
│ Receives OpenAI-compatible requests          │
└──────────────────────┬───────────────────────┘
                       │
                       │ Hetzner's internal
                       │ inference infrastructure
                       ▼
┌──────────────────────────────────────────────┐
│         Hetzner Model Server (vLLM)          │
│                                              │
│   Hetzner GPUs / inference cluster           │
│   • Qwen/Qwen3.6-35B-A3B-FP8                 │
└──────────────────────────────────────────────┘

That’s the whole architecture of everything we did in this post.

Wrapping Up

That’s the tour. Qwen 3.6 on Hetzner’s free endpoint.

What I like about the Experiments platform is that it feels different from what other cloud hosting companies are doing. Hetzner has engineers building things internally, and this is where they get to put those things in front of people and find out if anyone cares. Go try it out while it’s still free and let me know what you think!

ZazenCodes

Agentic Coding Club

Now live onSkool
  • Weekly LIVE build sessions — 30 min building, 30 min Q&A
  • Free to join, full course library with Premium
Join Free

Comments (0)

No comments yet.