📦 OpenAI SDK Usage Guide

Complete guide to use OpenAI SDK with v98store proxy API

This guide demonstrates how to use the OpenAI SDK with v98store proxy API. You can use the official OpenAI SDK in both TypeScript/JavaScript and Python by simply changing the baseURL to point to v98store.

⚙️ Configuration

Key Configuration Changes

To use v98store proxy API, you only need to change two things:

  • baseURL: Change from https://api.openai.com/v1 to https://v98store.com/v1
  • apiKey: Use your API key from the v98store API Tokens page

Important: Replace <YOUR_API_KEY> in the examples below with your actual API key from v98store.

📘 TypeScript/JavaScript Example

Installation

First, install the OpenAI SDK package:

npm install openai

Or if you're using yarn:

yarn add openai

Basic Usage Example

Here's a complete example using TypeScript/JavaScript:

TypeScript/JavaScript import OpenAI from 'openai'; const openai = new OpenAI({ baseURL: 'https://v98store.com/v1', apiKey: '<YOUR_API_KEY>', }); async function main() { const completion = await openai.chat.completions.create({ model: 'gpt-4o', messages: [ { role: 'user', content: 'What is the meaning of life?', }, ], }); console.log(completion.choices[0].message); } main();

Key Points:

  • Set baseURL to https://v98store.com/v1
  • Use your v98store API key in the apiKey field
  • All other OpenAI SDK methods work exactly the same

🐍 Python Example

Installation

First, install the OpenAI Python package:

pip install openai

Or if you're using pip3:

pip3 install openai

Basic Usage Example

Here's a complete example using Python:

Python from openai import OpenAI client = OpenAI( base_url="https://v98store.com/v1", api_key="<YOUR_API_KEY>", ) completion = client.chat.completions.create( model="gpt-4o", messages=[ { "role": "user", "content": "What is the meaning of life?" } ] ) print(completion.choices[0].message.content)

Key Points:

  • Set base_url to https://v98store.com/v1
  • Use your v98store API key in the api_key parameter
  • All other OpenAI SDK methods work exactly the same

Additional Features

Supported Operations

The v98store proxy API supports all standard OpenAI API operations:

  • Chat Completions: chat.completions.create()
  • Embeddings: embeddings.create()
  • Image Generation: images.generate()
  • Audio Transcription: audio.transcriptions.create()
  • Audio Translation: audio.translations.create()
  • Fine-tuning: All fine-tuning operations
  • Files: File upload and management
  • Assistants API: Full assistants functionality

Model Selection

You can use any model available through v98store. Simply specify the model name in your request:

// TypeScript/JavaScript model: 'gpt-4o' model: 'gpt-4-turbo' model: 'gpt-3.5-turbo' model: 'claude-3-opus' // ... and many more

Check the Model Prices page to see all available models.

💡 Best Practices

Environment Variables

For better security, store your API key in environment variables:

TypeScript/JavaScript:

const openai = new OpenAI({ baseURL: 'https://v98store.com/v1', apiKey: process.env.V98STORE_API_KEY, });

Python:

import os from openai import OpenAI client = OpenAI( base_url="https://v98store.com/v1", api_key=os.getenv("V98STORE_API_KEY"), )

Error Handling

Always include proper error handling in your code:

TypeScript/JavaScript:

try { const completion = await openai.chat.completions.create({ model: 'gpt-4o', messages: [{ role: 'user', content: 'Hello!' }], }); console.log(completion.choices[0].message); } catch (error) { console.error('Error:', error); }

Python:

try: completion = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "Hello!"}] ) print(completion.choices[0].message.content) except Exception as e: print(f"Error: {e}")