Skip to main content

Installation

Install using your favourite runtime

npm install @middlebop/client

Create your first chat completion

import { sendChat } from "@middlebop/client";

const middlebopApiKey = "mb-yourSuperSecretApiKey";

const messages: MiddlebopChatMessage[] = [
{
role: "user",
content: {
type: "text",
text: "Hello, who are you?",
},
},
];

const response = await sendChat({
messages,
model: "gpt-4",
middlebopApiKey,
});

console.log(response.data);

The response and input messages will always follow the middleop standard syntax no matter which ai model you communicate with

response.data
{
"responseMessages": [
{
"role": "assistant",
"content": {
"type": "text",
"text": "Hello! I'm AI developed by OpenAI. How can I help you today?"
}
}
]
}