As long as there's a openapi.json available at the domain, you can import a type safe fetch-function as follows:
```typescript
// Save this as test.ts and run it using `deno run --allow-net --allow-import test.ts`
// Import the chat completion function directly
import createChatCompletion from "https://oapis.org/ts/chatcompletions.com/createChatCompletio...";
// Use it without any SDK installation
const completion = await createChatCompletion({
headers: {
"X-LLM-API-Key": "YOUR_SECRET",
"X-LLM-Base-Path": "https://api.deepseek.com/v1",
},
body: {
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Hello!" },
],
model: "deepseek-chat",
},
});if (completion.body) {
console.log(completion.body.choices[0].message.content);
//Hello! How can I assist you today?
} else { console.log("ERROR", completion.status);
}// This works like a charm!
```
Hope you like it. Feedback appreciated!