Skip to content

Chat Completion

Shows how to use the OpenAI-compatible chat completion endpoint to run inference on a Predibase deployment.

This example assumes using Predibase; is in scope and apiKey contains your Predibase API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
using var client = new PredibaseClient(apiKey);

// Send a chat completion request to a deployment.
var response = await client.Inference.ChatCompletionAsync(
    deploymentName: DeploymentName,
    request: new ChatCompletionRequest
    {
        Messages =
        [
            new ChatMessage
            {
                Role = "user",
                Content = "What is LoRA fine-tuning?",
            },
        ],
        MaxTokens = 256,
        Temperature = 0.7f,
    });