TypeScript types for the Bodhi API, providing type-safe access to the API endpoints.
npm install @bodhiapp/ts-client
import { ChatRequest } from "@bodhiapp/ts-client";
// Example chat request with type safety
const request: ChatRequest = {
model: "llama2",
messages: [
{ role: "user", content: "Hello, who are you?" }
],
options: {
temperature: 0.7,
num_predict: 100
},
stream: false
};
// Make API calls using your preferred HTTP client
async function chatWithBodhi() {
const response = await fetch("http://localhost:3000/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(request)
});
const data = await response.json();
console.log(data.choices[0].message.content);
}
This package provides TypeScript types generated from the Bodhi API OpenAPI specification.
To regenerate the types:
npm run generate
This will:
- Generate the OpenAPI spec from the Rust backend
- Generate TypeScript types using @hey-api/openapi-ts
To build the package:
npm run build
To run tests:
npm test
The package exports TypeScript interfaces for all Bodhi API requests and responses. The main types include:
ChatRequest
- Type for chat completion requestsMessage
- Type for chat messagesAppInfo
- Application information and statusModel
- Model informationApiToken
- API token information- And more...
All types are fully documented with JSDoc comments for better IDE integration.