Skip to content

Chat Completion

Basic example showing how to create a chat completion via the Martian Gateway.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
using var client = new MartianClient(apiKey);

// Send a chat completion request through the Martian Gateway
var response = await client.CreateChatCompletionAsync(
    model: "openai/gpt-4.1-nano",
    messages: [new ChatCompletionMessage
    {
        Role = ChatCompletionMessageRole.User,
        Content = "What is 2 + 2?",
    }]);