Transition from OpenAI
The Compsessa API is OpenAI compatible.
If your code has previously used OpenAI package directly, without using Langchain, you can just use the OpenAI package with our endpoints.
For example for official python OpenAI client:
pip install openai
Create client:
client = OpenAI(
api_key="<COMPRESSA_API_KEY>",
base_url="https://compressa-api.mil-team.ru/v1"
)
And next, just use:
Chat API
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Say this is a test",
}
],
model="compressa-ai_Llama-3-8B-Instruct",
)
print(chat_completion)
Embeddings API
embedding = client.embeddings.create(
model="Salesforce_SFR-Embedding-Mistral",
input="What is the capital of the United States?",
encoding_format="float"
)
print(embedding)