hashbrown

Getting Started

Guide

  1. 1. Basics of AI
  2. 2. System Instructions
  3. 3. Skillet Schema
  4. 4. Streaming
  5. 5. Tool Calling
  6. 6. Structured Output
  7. 7. Generative UI
  8. 8. JavaScript Runtime

Recipes

  1. Natural Language Forms
  2. UI Chatbot with Tools
  3. Predictive Suggestions
  4. Remote MCP

Platforms

Microsoft Azure

First, install the Microsoft Azure adapter package:

npm install @hashbrownai/azure

Usage

Currently, our Azure adapter only supports text streaming:

import { Chat } from '@hashbrownai/core';
import { HashbrownAzure } from '@hashbrownai/azure';

app.post('/chat', async (req, res) => {
  const request = req.body as Chat.CompletionCreateParams;
  const stream = HashbrownAzure.stream.text({
    apiKey: AZURE_API_KEY,
    endpoint: AZURE_ENDPOINT,
    request,
  });

  res.header('Content-Type', 'application/octet-stream');

  for await (const chunk of stream) {
    res.write(chunk);
  }

  res.end();
});

Let's break this down:

  • HashbrownAzure.stream.text is a function that takes an API Key, an endpoint, and a Hashbrown request object, and returns an async iterable stream of encoded data ready to be sent to your frontend. It handles any internal errors that may occur, and forwards them to your frontend.
  • req.body is the request object that contains the parameters for the chat completion.
  • res.header sets the response header to application/octet-stream, which is required for streaming binary data to your app.
  • res.write writes each chunk to the response as it arrives.
  • res.end closes the response when the stream is finished.

Model Versions

Azure requires model versions to be supplied when making a request. To do this, specify the model version in the model string when supplied to any resource:

completionResource({
  model: 'gpt-4o@2025-01-01-preview',
  // ...
});
Microsoft Azure Usage Model Versions