The Crosshatch API is designed to be compatible with the OpenAI API. This makes it easy for you to use Crosshatch anywhere you use those existing OpenAI APIs, client libraries, or compatible frameworks.
Configuring OpenAI to use Crosshatch
To use Crosshatch where you are already using OpenAI, you will need to change 3 values:
Base URL will point to https://api.crosshatch.app/v1
Model will be your preferred Model Mix, discoverable on the Model Mix list page.
import OpenAI from"openai";constopenai=newOpenAI({ apiKey:"<YOUR-API-KEY>", baseURL:"https://api.crosshatch.app/v1"});constcompletion=awaitclient.chat.completions.create({ messages: [{ role:'user', content:'Say this is a test' }], model:'lmsys-overall',// <-- Your Model Mix});
from openai import OpenAIclient =OpenAI( api_key="your_api_key_here", base_url="https://api.crosshatch.app/v1")chat_completion = client.chat.completions.create( messages=[ {"role": "user","content": "Say this is a test", } ], model="lmsys-overall", # <-- this is your Model Mix)
curl-L \-XPOST \-H'Content-Type: application/json' \'https://api.crosshatch.app/v1/chat/completions' \-H'Authorization: Bearer <YOUR_API_KEY>' \-d'{"model":"lmsys-overall","messages":[{"content":"Say this is a test","role":"user"}]}'