openai/openai-dotnet

Public

mirrored from https://github.com/openai/openai-dotnetAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/fix-codeinterpretertoolcontainer

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

docs/guides/tools-connectors-mcp/responses/authentication.cs

28lines · modecode

1// SAMPLE: Generate response from remote MCP through Responses API
2// PAGE: https://platform.openai.com/docs/guides/tools-connectors-mcp#authentication
3// GUIDANCE: Instructions to run this code: https://aka.ms/oai/net/start
4#pragma warning disable OPENAI001
5
6#:package OpenAI@2.*
7
8using OpenAI.Responses;
9
10string authToken = Environment.GetEnvironmentVariable("STRIPE_OAUTH_ACCESS_TOKEN")!;
11string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
12ResponsesClient client = new(key);
13
14CreateResponseOptions options = new() { Model = "gpt-5.2" };
15options.Tools.Add(
16 ResponseTool.CreateMcpTool(
17 serverLabel: "stripe",
18 serverUri: new Uri("https://mcp.stripe.com"),
19 authorizationToken: authToken
20 )
21);
22options.InputItems.Add(
23 ResponseItem.CreateUserMessageItem("Create a payment link for $20")
24);
25
26ResponseResult response = client.CreateResponse(options);
27
28Console.WriteLine(response.GetOutputText());