OpenAI SDK for .NET 2.13.0

Last reviewed Sep 19, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. C# 14106 lines · 4.4K tokens
  2. OpenAI SDK for .NET 2.13.073 lines · 3.3K tokens
Total179 lines · 7.7K tokens

CWE Coverage

  • 20
  • 22
  • 59
  • 73
  • 78
  • 89
  • 94
  • 117
  • 190
  • 201
  • 208
  • 209
  • 214
  • 250
  • 257
  • 295
  • 306
  • 319
  • 323
  • 327
  • 338
  • 347
  • 362
  • 367
  • 378
  • 426
  • 502
  • 532
  • 611
  • 639
  • 674
  • 759
  • 770
  • 772
  • 775
  • 798
  • 807
  • 841
  • 862
  • 863
  • 915
  • 916
  • 918
  • 1333
  • 1395
  • 1426
  • 1427

Prompt Preview

Apply the C# 14 prompt first. These rules cover the official OpenAI NuGet package 2.13.0 in C# 14/.NET 10 applications. Its additional .NET 8 and .NET Standard 2.0 assets establish compatibility, not the support lifecycle of every compatible runtime.

Clients, credentials, and transport

  • Authenticate and authorize application callers before invoking the SDK. Use protected project or service-account credentials on the server; an OpenAI API key does not establish the caller's application permissions.
  • Reuse thread-safe clients for each fixed credential, endpoint, and project configuration. Keep request options, message histories, and resource-ID mappings isolated per caller; do not rotate a shared ApiKeyCredential to impersonate different tenants.
  • Set Endpoint, OrganizationId, ProjectId, authentication policies, and transports only from trusted configuration. Use ResponsesClientOptions for direct ResponsesClient construction and OpenAIClientOptions for OpenAIClient and ChatClient; restrict credential-bearing traffic to approved HTTPS destinations, including custom proxies and redirects.
  • Configure finite NetworkTimeout values and pass a cancellation token with an overall deadline to SDK operations. NetworkTimeout bounds individual network operations, not the complete retry, polling, or tool-execution workflow.
  • Budget for up to three additional attempts on HTTP 408, 429, 500, 502, 503, and 504 by default. Configure RetryPolicy with ClientRetryPolicy, using zero retries when replay is unsafe; bound any outer retry loop and reconcile