Skip to content

yttug #1656

Description

@geh91

import ModelClient, { isUnexpected } from "@azure-rest/ai-inference";
import { AzureKeyCredential } from "@azure/core-auth";

const token = process.env["GITHUB_TOKEN"];
const endpoint = "https://models.github.ai/inference";
const model = "openai/gpt-4.1";

export async function main() {

const client = ModelClient(
endpoint,
new AzureKeyCredential(token),
);

const response = await client.path("/chat/completions").post({
body: {
messages: [
{ role:"system", content: "You are a helpful assistant." },
{ role:"user", content: "What is the capital of France?" }
],
temperature: 1.0,
top_p: 1.0,
model: model
}
});

if (isUnexpected(response)) {
throw response.body.error;
}

console.log(response.body.choices[0].message.content);
}

main().catch((err) => {
console.error("The sample encountered an error:", err);
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions