Venice’s text inference API implements the OpenAI API specification, ensuring compatibility with existing OpenAI clients and tools. This document outlines how to integrate with Venice using this familiar interface.

Base Configuration

Required Base URL

All API requests must use Venice’s base URL:

const BASE_URL = "https://api.venice.ai/api/v1"

Client Setup

Configure your OpenAI client with Venice’s base URL:

import OpenAI from "openai";

new OpenAI({
  apiKey: "--Your API Key--",
  baseURL: "https://api.venice.ai/api/v1",
});

Available Endpoints

Models

  • Endpoint: /api/v1/models
  • Documentation: Models API Reference
  • Purpose: Retrieve available models and their capabilities

Chat Completions

System Prompts

Venice provides default system prompts designed to ensure uncensored and natural model responses. You have two options for handling system prompts:

  1. Default Behavior: Your system prompts are appended to Venice’s defaults
  2. Custom Behavior: Disable Venice’s system prompts entirely

Disabling Venice System Prompts

Use the venice_parameters option to remove Venice’s default system prompts:

const completionStream = await openAI.chat.completions.create({
  model: "default",
  messages: [
    {
      role: "system",
      content: "Your system prompt",
    },
    {
      role: "user",
      content: "Why is the sky blue?",
    },
  ],
  // @ts-expect-error Venice.ai paramters are unique to Venice.
  venice_parameters: {
    include_venice_system_prompt: false,
  },
});

Best Practices

  1. Error Handling: Implement robust error handling for API responses
  2. Rate Limiting: Be mindful of rate limits during the beta period
  3. System Prompts: Test both with and without Venice’s system prompts to determine the best fit for your use case
  4. API Keys: Keep your API keys secure and rotate them regularly

Differences from OpenAI’s API

While Venice maintains high compatibility with the OpenAI API specification, there are some Venice-specific features and parameters:

  1. venice_parameters: Additional configuration options specific to Venice
  2. System Prompts: Different default behavior for system prompt handling
  3. Model Names: Venice-specific model identifiers