Menu

Compare Three LLM APIs With One Python Script and a Test You Can Score
📰

Compare Three LLM APIs With One Python Script and a Test You Can Score

DEV Community: python·Mattias chaw·3 days ago
#N1EyVXol
#devtopython#devto#dev#model#urgent
Long article (1898 words) — no AI summary yet.
Reading 0:00
15s threshold

When a model returns a plausible-looking answer, it can still fail the contract your application depends on. Imagine a support workflow that expects {"intent":"billing","urgent":false} . One model returns that object. Another puts it in a Markdown fence. A third returns "false" as a string. They look similar in a chat window, but only one passes a strict parser. In Python, bool("false") is True . Silently coercing the result can route tickets to the wrong queue.

Here's a small test that separates three questions: did the HTTP request succeed, did the answer match the required shape, and did the model make the right decision? It uses synthetic tickets, a fixed rubric, and nothing outside Python's standard library. The example uses AIWave, which I operate. You can use the same script with another endpoint that implements OpenAI-style /chat/completions by changing the base URL, credential and model IDs. AI was used to help prepare this article.

1.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.