LogoLogo
Tonic Validatetonic_validateDocs homeTonic.ai
  • Tonic Validate guide
  • About Tonic Validate
    • What is Tonic Validate?
    • Validate components and tools
    • Validate workflows
  • Getting started with Validate
    • Starting your Validate account
    • Setting up the Validate SDK
    • Quickstart example - create a run and log responses
    • Creating and revoking Validate API keys
  • About RAG metrics
    • About using metrics to evaluate a RAG system
    • RAG components summary
    • RAG metrics summary
    • RAG metrics reference
  • Benchmarks and projects
    • Managing benchmarks in Validate
    • Managing projects in Validate
  • Runs
    • Starting a Validate run
    • Viewing and managing runs
  • Production monitoring
    • Configuring your RAG system to send questions to Validate
    • Viewing the metric scores and logged questions
  • Code examples
    • End-to-end example using LlamaIndex
Powered by GitBook
On this page
  • Installing the Validate SDK
  • Setting the Validate API key environment variable
  • Obtaining and providing an API key for the LLM evaluator
  • Using the OpenAI API
  • Using Azure's OpenAI service
  • Using the Gemini API
  • Using the Anthropic API

Was this helpful?

Export as PDF
  1. Getting started with Validate

Setting up the Validate SDK

Last updated 1 year ago

Was this helpful?

Installing the Validate SDK

To install tonic_validate, you use pip:

pip install tonic-validate

Setting the Validate API key environment variable

To log metrics using tonic_validate, you need to set the API key by passing it into ValidateApi

from tonic_validate import ValidateApi
validate_api = ValidateApi("your-api-key")

Obtaining and providing an API key for the LLM evaluator

Validate uses LLM-assisted evaluation. You must provide an API key for the LLM evaluator model that you want to use.

Validate currently supports the following models:

Using the OpenAI API

To use the OpenAI models, you must:

  • Have an OpenAI API key

  • Set the API key as the value of the environment variable OPENAI_API_KEY

In your Python script or Jupyter notebook, set your Open AI API key as the value of OPENAI_API_KEY:

import os
os.environ["OPENAI_API_KEY"] = "put-your-openai-api-key-here"

Using Azure's OpenAI service

Validate also supports Azure's OpenAI API service.

To use Azure, you must set up an Azure OpenAI deployment.

After you set up your deployment, copy your API key and API endpoint to the following environment variables:

import os
os.environ["AZURE_OPENAI_KEY"] = "put-your-azure-openai-api-key-here"
os.environ["AZURE_OPENAI_ENDPOINT"] = "put-your-azure-endpoint-here"

Using the Gemini API

To use Gemini models, you must:

  • Have a Gemini API key

  • Set the API key as the value of the environment variable GEMINI_API_KEY

In your Python script or Jupyter notebook, set your Gemini API key as the value of GEMINI_API_KEY:

import os
os.environ["GEMINI_API_KEY"] = "put-your-gemini-api-key-here"

Using the Anthropic API

To use Anthropic models, you must:

  • Have a Anthropic API key

  • Set the API key as the value of the environment variable ANTHROPIC_API_KEY

In your Python script or Jupyter notebook, set your Anthropic API key as the value of ANTHROPIC_API_KEY:

import os
os.environ["ANTHROPIC_API_KEY"] = "put-your-anthropic-api-key-here"

To get an Open AI API key, go to .

For information on how to set up a deployment, go to this .

When you , you must provide the deployment name.

To get a Gemini API key, go to the .

To get a Anthropic API key, go to the .

OpenAI
Azure OpenAI service
Gemini
Anthropic
the OpenAI API key page
Azure OpenAI service quickstart
start a Validate run
Gemini home page
Anthropic API page