Back to blog

Getting startedGuide

First request to CheapTokens in Hoppscotch: key in an environment

Send your first chat completion from the Hoppscotch web client: base URL and key in an environment, a JSON body, and where to read the reply and usage.

By CheapTokens TeamPublished 4 min read

Hoppscotch request: POST to the base URL from an environment with a Bearer key variable
On this page
  1. Put the base URL and the key into an environment
  2. Build the request
  3. Press Send and read the reply
  4. What a test request costs
  5. If it doesn't work
  6. Where to go next

You can make your first CheapTokens request in Hoppscotch without installing anything or writing code: open the web app, put the base URL and your key into an environment, build one POST /chat/completions request, press Send. The answer and the token counts show up in the response panel.

The only thing worth doing carefully is the key. If you paste it straight into the request, it ends up in every screenshot and every shared link. An environment variable keeps it in one place.

This guide follows the official Hoppscotch docs (checked 9 November 2026; the pages carry no version or date). The API side is the CheapTokens base URL https://api.cheaptokens.dev/v1, which speaks the OpenAI Chat Completions format. More on both in the CheapTokens docs.

Put the base URL and the key into an environment#

Hoppscotch has an Environments icon in the sidebar. Click it, create a new environment, name it cheaptokens, and add two variables:

Variable Type Value
baseURL Regular https://api.cheaptokens.dev/v1
api_key Secret your CheapTokens key

Why two types? Per the Hoppscotch docs, a Regular variable is visible to everyone who can see the environment, while a Secret one is masked, never synced or shared, and left out of exports and duplicates. A key belongs in the second kind: enter it as the variable's value. Then select the cheaptokens environment so the request can see it.

In requests, a variable is written as <<name>>: <<baseURL>> and <<api_key>>. That's the whole trick.

The request fields to fill in Hoppscotch: URL, header and JSON body (schematic, not a screenshot)
The request as it is set up in this guide: method, URL from the environment, header, JSON body.

Build the request#

REST is the active mode when you open Hoppscotch. Three things to set.

Method and URL. Choose POST in the dropdown and enter:

text
<<baseURL>>/chat/completions

The key. Hoppscotch's Authorization tab has a Bearer type and adds the token to the request as Bearer <token>. The docs don't say whether <<api_key>> works inside that token field, so use the sure route: open the Headers tab and add one header.

text
Authorization: Bearer <<api_key>>

You replace the variable by hand nowhere, and the real key never appears in the request you see on screen.

The body. Open the Body tab, choose application/json in the Content Type dropdown (the docs list it as the type for content in JSON format), and paste:

json
{
  "model": "deepseek-ai/DeepSeek-V4-Flash-0731",
  "messages": [
    {"role": "user", "content": "Explain what a token is in one sentence."}
  ],
  "max_tokens": 200
}

Use the full id deepseek-ai/DeepSeek-V4-Flash-0731. The short name from a price list won't be accepted by the API. DeepSeek-V4-Flash has a 380K context and up to 32,768 output tokens per answer, so 200 is a deliberately small cap for a test. Want a different model? Change that one field to zai-org/GLM-5.3-Flash (390K context, up to 8,192 output tokens) and send again.

Checklist

Before you press Send

Press Send and read the reply#

Click Send. The response section shows the status code, body, headers, cookies and timing. You want 200 and a JSON body shaped like the OpenAI chat completion format. Two places matter:

  • choices[0].message.content is the model's answer.
  • usage has prompt_tokens (what you sent) and completion_tokens (what the model wrote). That's what you're billed for, so this is where you check a request cost what you expected.

Also look at choices[0].finish_reason. stop means the model finished on its own. length means your max_tokens cut the answer off. If you see that on a one-sentence question, the cap is too low. There's a longer explanation in AI answer cut off? Fix finish_reason "length".

Where to look in the response
Fields to read in the response body. The values are placeholders, not a recorded reply.

Save the request into a collection and it's reusable: change the message, press Send again.

What a test request costs#

Take a short question and a short answer: say 30 tokens in and 150 out. One such request costs $0.000015, and the live table below counts 100 of them with input and output together, next to OpenRouter.

Model Per request 100 requests OpenRouter, 100 requests
GLM-5.3-Flash $0.0000066 $0.00066 $0.0013
DeepSeek-V4-Flash $0.000015 $0.0015 $0.0023
MiniMax-M2.7 $0.000024 $0.0024 $0.0288

30 input and 150 output tokens per request. Prices per 1M tokens are current and change together with our tariffs; the OpenRouter column shows reference prices for the same workload.

In total, with input and output counted together, that's cheaper than OpenRouter for the same model. Your own numbers will differ, so drag the sliders on your own case:

Cost calculator

A hundred test requests like the one above

Input tokens per request: 30 · Output tokens per request: 150 · Requests per day: 100

ModelPer dayPer month
GLM-5.3-Flash$0.00066$0.0198
DeepSeek-V4-Flash$0.0015$0.0464
MiniMax-M2.7$0.0024$0.072

Prices are fixed per model, with no peak-hour pricing, and one balance covers all models. The current rates are on the pricing page.

If it doesn't work#

Most first-request failures in a REST client come from three fields. Match the symptom to the cause:

Match the pairs

Match each symptom to its cause

  • 401 UnauthorizedThe key is missing or wrong, or the Authorization header isn't being sent
  • 404 Not FoundThe URL path or the model id is wrong
  • finish_reason is "length"The max_tokens cap cut the answer off

For the first two there's a full walk-through in API 401 or 404 error: wrong key, base URL or model id. If you're not sure which id to use, list models with GET /v1/models.

Where to go next#

The same request works in other clients: see the Postman version or the VS Code .http file. If you'd rather keep keys out of files and shells entirely, store an API key safely covers the basics. Model ids and the OpenAI-compatible endpoint are described in the docs.