GPTBoost Documentation
  • Welcome
  • First Steps
    • Create Account
    • Authorize Keys
    • OpenAI Integration
    • Azure Integration
    • Streaming
    • Analyze Logs
  • Features
    • Summary & Metrics
    • Request logs
    • Error Logs
    • Models Usage
    • Annotation Agents
    • User Feedback & Voting
      • Integration
      • The Value of User Feedback
  • Advanced
    • Proxy Overview
    • Configuration params
    • Omit Logging
    • GPTBoost Props
    • Namespaces
    • Function Usage
  • Security
    • IP Security
      • Allow Only IPs
      • Block Only IPs
  • Collaborate
    • About Teams
    • Create a Team
    • Invite the Crew
Powered by GitBook
On this page

Was this helpful?

  1. First Steps

OpenAI Integration

A single line added to your code makes all the difference

PreviousAuthorize KeysNextAzure Integration

Last updated 1 year ago

Was this helpful?

All that needs to be done in order to add GPTboost functionality to your LLM app, is add one single line to your code: openai.api_base = "https://turbo.gptboost.ai/v1. Next, per each request made to LLM specified, GPTBoost will collect all the essential data for you.

# This example is for v1+ of the openai: https://pypi.org/project/openai/
from openai import OpenAI

client = OpenAI( 
    # GPTBoost API base URL
    base_url = "https://turbo.gptboost.io/v1",
    api_key = $OPENAI_API_KEY,
)

response = client.chat.completions.create(
    model="gpt-3.5-turbo",
    messages=[
        {"role": "user", "content": "Tell me an interesting fact about pandas"},
    ], 
)

print(response.choices[0].message.content)
curl --request POST \
--url https://turbo.gptboost.io/v1/chat/completions \
--header 'Authorization: Bearer $OPENAI_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
    "model": "gpt-3.5-turbo",
    "messages": [
        {
            "role": "user",
            "content": "Tell me an interesting fact about koalas!"
        }
    ]
}'
    
// This code is for v4+ of the openai package: npmjs.com/package/openai
import OpenAI from 'openai';

const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
  baseURL: "https://turbo.gptboost.io/v1",
});

async function ask_gpt(){ 
    const response = await openai.chat.completions.create({
        model: "gpt-3.5-turbo",
        messages: [{ role: "user", content: "Get me 3 inspirational quotes" }],
    });
    console.log(response.choices[0].message.content)
}

ask_gpt()

* Make sure to place the openai.api_base before the completion.

What happens behind the scenes is that GPTBoost and gathers all needed information from the prompts and completions. Now you can search, filter sort and analyze with ease from the beautiful GPTBoost interface.

IMPORTANT: Make sure you add the GPTboost base URL only to apps whose OpenAI API keys have been added to GPTboost. To log requests, GPTBoost serves as a proxy between your app and OpenAI. Hence, if you add the GPTBoost URL but do not have the OpenAI key added to your GPTBoost account, requests to OpenAI will not be authorized and stop processing!

serves as a Proxy