Text Generator Brain Text Generator
Text Generator > Blog > 10x OpenAI Cost Savings - One Line Change

10x OpenAI Savings - One Line Change

We created an OpenAI compatible endpoint to make migrating simple!

Step 1 - Get an API Key

Sign Up to Text-Generator.io then get your API key

Step 2 - Change Your API Key + Base Url

Python OpenAI Library
import os
import openai

# Load your API key from an environment variable or secret management service
--openai.api_key = os.getenv("OPENAI_API_KEY")
++openai.api_key = os.getenv("TEXTGENERATOR_API_KEY") # your key from Text-Generator.io
++openai.api_base = "https://api.text-generator.io"

response = openai.Completion.create(model="text-davinci-002", prompt="Say this is a test", temperature=0, max_tokens=6)
Node OpenAI Library
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
--  apiKey: process.env.OPENAI_API_KEY,
++  apiKey: process.env.TEXTGENERATOR_API_KEY, // your key from Text-Generator.io
++  basePath: "https://api.text-generator.io/v1"
const openai = new OpenAIApi(configuration);

const completion = await openai.createCompletion({
  model: "text-davinci-002",
  prompt: "Hello world",
  max_tokens: 10,
Important differences

There are some OpenAI concepts that are not implemented in the Text Generator API

  • Only completion is implemented, other operations in OpenAI will no longer work
  • frequency/presence penalty not supported - Text-Generator.io uses a repetition_penalty only exposed in the HTTP JSON API
  • Models are not exposed in TextGenerator.io so the model name doesn't make a difference - generating multiple languages and code still work.
  • Editing api is not supported, (suffix param is ignored)
  • Log probabilities are not returned
  • tokenization counting in the response isn't implemented, you don't have to closely monitor tokenization anymore and are charged per request
  • Our models are smaller than Davinci - some advanced instruction following such as language translation may not work as well.
Features that OpenAI doesn't yet support

There are more controls like min_probability to generate a short likely autocomplete as well as a max_sentence parameter only supported in the Text Generator.io HTTP JSON API so consider switching to that.


We think OpenAI is 10x too expensive right now, so we bet on it! If you send us your usage (currie/babbage/davinci) this month and havn't seen 10x cost savings after switching for a month, we will drop pricing for everyone to make sure it's a 10x cost savings.

We hope having 10x cheaper text generation will enable an order of magnitude more benefits from this new technology.


Text Generator offers an API for text and code generation. Secure (no PII is stored on our servers), affordable, flexible and accurate.

Try examples yourself at: Text Generator Playground