diff --git a/docs/guides/images-vision/responses/analyze_images_passing_base64_string.cs b/docs/guides/images-vision/responses/analyze_images_passing_base64_string.cs index 1fd56f963..c440e9acd 100644 --- a/docs/guides/images-vision/responses/analyze_images_passing_base64_string.cs +++ b/docs/guides/images-vision/responses/analyze_images_passing_base64_string.cs @@ -17,7 +17,7 @@ // Download an image as stream using var stream = await http.GetStreamAsync(imageUrl); -OpenAIResponse response1 = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response1 = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("What is in this image?"), ResponseContentPart.CreateInputImagePart(BinaryData.FromStream(stream), "image/png") @@ -29,7 +29,7 @@ // Download an image as byte array byte[] bytes = await http.GetByteArrayAsync(imageUrl); -OpenAIResponse response2 = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response2 = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("What is in this image?"), ResponseContentPart.CreateInputImagePart(BinaryData.FromBytes(bytes), "image/png") diff --git a/docs/guides/images-vision/responses/analyze_images_passing_file.cs b/docs/guides/images-vision/responses/analyze_images_passing_file.cs index 0cb3fd622..0a8c8aad7 100644 --- a/docs/guides/images-vision/responses/analyze_images_passing_file.cs +++ b/docs/guides/images-vision/responses/analyze_images_passing_file.cs @@ -22,7 +22,7 @@ OpenAIFileClient files = new(key); OpenAIFile file = await files.UploadFileAsync(BinaryData.FromStream(stream), filename, FileUploadPurpose.Vision); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("what's in this image?"), ResponseContentPart.CreateInputImagePart(file.Id) diff --git a/docs/guides/images-vision/responses/analyze_images_passing_url.cs b/docs/guides/images-vision/responses/analyze_images_passing_url.cs index 003da272d..3f506cd62 100644 --- a/docs/guides/images-vision/responses/analyze_images_passing_url.cs +++ b/docs/guides/images-vision/responses/analyze_images_passing_url.cs @@ -13,7 +13,7 @@ Uri imageUrl = new("https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("What is in this image?"), ResponseContentPart.CreateInputImagePart(imageUrl) diff --git a/docs/guides/text/responses/responses_fileinput.cs b/docs/guides/text/responses/responses_fileinput.cs index f20a93da1..0912447e7 100644 --- a/docs/guides/text/responses/responses_fileinput.cs +++ b/docs/guides/text/responses/responses_fileinput.cs @@ -16,7 +16,7 @@ OpenAIFileClient files = new(key); OpenAIFile file = files.UploadFile("draconomicon.pdf", FileUploadPurpose.UserData); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse( +OpenAIResponse response = client.CreateResponse( BinaryContent.Create(BinaryData.FromObjectAsJson( new { model = "gpt-4.1", diff --git a/docs/guides/text/responses/responses_prompttemplate.cs b/docs/guides/text/responses/responses_prompttemplate.cs index e8180f718..10339c641 100644 --- a/docs/guides/text/responses/responses_prompttemplate.cs +++ b/docs/guides/text/responses/responses_prompttemplate.cs @@ -10,7 +10,7 @@ string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!; OpenAIResponseClient client = new("gpt-4.1", key); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse( +OpenAIResponse response = client.CreateResponse( BinaryContent.Create(BinaryData.FromObjectAsJson( new { model = "gpt-4.1", diff --git a/docs/guides/tools-connectors-mcp/responses/approvals-always-require-approval.cs b/docs/guides/tools-connectors-mcp/responses/approvals-always-require-approval.cs index 841132206..25e9ebaa5 100644 --- a/docs/guides/tools-connectors-mcp/responses/approvals-always-require-approval.cs +++ b/docs/guides/tools-connectors-mcp/responses/approvals-always-require-approval.cs @@ -19,7 +19,7 @@ )); // STEP 1: Create response that requests tool call approval -OpenAIResponse response1 = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response1 = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("Roll 2d4+1") ]) @@ -29,7 +29,7 @@ // STEP 2: Approve the tool call request and get final response options.PreviousResponseId = response1.Id; -OpenAIResponse response2 = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response2 = client.CreateResponse([ ResponseItem.CreateMcpApprovalResponseItem(approvalRequestItem!.Id, approved: true), ], options); diff --git a/docs/guides/tools-connectors-mcp/responses/approvals-never-require-approval.cs b/docs/guides/tools-connectors-mcp/responses/approvals-never-require-approval.cs index dd1a1b0bf..a52e80ec4 100644 --- a/docs/guides/tools-connectors-mcp/responses/approvals-never-require-approval.cs +++ b/docs/guides/tools-connectors-mcp/responses/approvals-never-require-approval.cs @@ -19,7 +19,7 @@ toolCallApprovalPolicy: new McpToolCallApprovalPolicy(GlobalMcpToolCallApprovalPolicy.NeverRequireApproval) )); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("What transport protocols does the 2025-03-26 version of the MCP spec (modelcontextprotocol/modelcontextprotocol) support?") ]) diff --git a/docs/guides/tools-connectors-mcp/responses/authentication.cs b/docs/guides/tools-connectors-mcp/responses/authentication.cs index 4b05af96e..00f62aaf9 100644 --- a/docs/guides/tools-connectors-mcp/responses/authentication.cs +++ b/docs/guides/tools-connectors-mcp/responses/authentication.cs @@ -19,7 +19,7 @@ authorizationToken: authToken )); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("Create a payment link for $20") ]) diff --git a/docs/guides/tools-connectors-mcp/responses/filtering-tools.cs b/docs/guides/tools-connectors-mcp/responses/filtering-tools.cs index c87593f72..a7a9818da 100644 --- a/docs/guides/tools-connectors-mcp/responses/filtering-tools.cs +++ b/docs/guides/tools-connectors-mcp/responses/filtering-tools.cs @@ -19,7 +19,7 @@ toolCallApprovalPolicy: new McpToolCallApprovalPolicy(GlobalMcpToolCallApprovalPolicy.NeverRequireApproval) )); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("Roll 2d4+1") ]) diff --git a/docs/guides/tools-connectors-mcp/responses/quickstart-remote-mcp.cs b/docs/guides/tools-connectors-mcp/responses/quickstart-remote-mcp.cs index fe45027a0..dfec15404 100644 --- a/docs/guides/tools-connectors-mcp/responses/quickstart-remote-mcp.cs +++ b/docs/guides/tools-connectors-mcp/responses/quickstart-remote-mcp.cs @@ -18,7 +18,7 @@ toolCallApprovalPolicy: new McpToolCallApprovalPolicy(GlobalMcpToolCallApprovalPolicy.NeverRequireApproval) )); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("Roll 2d4+1") ]) diff --git a/docs/guides/tools-web-search/responses/quickstart.cs b/docs/guides/tools-web-search/responses/quickstart.cs index 4eb075d2f..044b71cbd 100644 --- a/docs/guides/tools-web-search/responses/quickstart.cs +++ b/docs/guides/tools-web-search/responses/quickstart.cs @@ -14,7 +14,7 @@ ResponseCreationOptions options = new(); options.Tools.Add(ResponseTool.CreateWebSearchTool()); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart( "What was a positive news story from today?" diff --git a/docs/guides/tools-web-search/responses/user-location.cs b/docs/guides/tools-web-search/responses/user-location.cs index b087e00f6..57a036472 100644 --- a/docs/guides/tools-web-search/responses/user-location.cs +++ b/docs/guides/tools-web-search/responses/user-location.cs @@ -20,7 +20,7 @@ ) )); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart( "What are the best restaurants near me?" diff --git a/docs/guides/tools/responses/file_search.cs b/docs/guides/tools/responses/file_search.cs index 889706882..c0bc066d1 100644 --- a/docs/guides/tools/responses/file_search.cs +++ b/docs/guides/tools/responses/file_search.cs @@ -14,7 +14,7 @@ ResponseCreationOptions options = new(); options.Tools.Add(ResponseTool.CreateFileSearchTool([ "" ])); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("What is deep research by OpenAI?") ]) diff --git a/docs/guides/tools/responses/function_calling.cs b/docs/guides/tools/responses/function_calling.cs index 27eaf1e7e..60758eea7 100644 --- a/docs/guides/tools/responses/function_calling.cs +++ b/docs/guides/tools/responses/function_calling.cs @@ -34,7 +34,7 @@ ) ); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("What is the weather like in Paris today?") ]) diff --git a/docs/guides/tools/responses/remote_mcp.cs b/docs/guides/tools/responses/remote_mcp.cs index 1dee77096..11f89d493 100644 --- a/docs/guides/tools/responses/remote_mcp.cs +++ b/docs/guides/tools/responses/remote_mcp.cs @@ -18,7 +18,7 @@ toolCallApprovalPolicy: new McpToolCallApprovalPolicy(GlobalMcpToolCallApprovalPolicy.NeverRequireApproval) )); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("Roll 2d4+1") ]) diff --git a/docs/guides/tools/responses/web_search.cs b/docs/guides/tools/responses/web_search.cs index f1cbece6e..dd26d2a68 100644 --- a/docs/guides/tools/responses/web_search.cs +++ b/docs/guides/tools/responses/web_search.cs @@ -14,7 +14,7 @@ ResponseCreationOptions options = new(); options.Tools.Add(ResponseTool.CreateWebSearchTool()); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart( "What was a positive news story from today?" diff --git a/docs/quickstart/responses/analyze_images_files_file_url.cs b/docs/quickstart/responses/analyze_images_files_file_url.cs index 3691e24e3..61d811b06 100644 --- a/docs/quickstart/responses/analyze_images_files_file_url.cs +++ b/docs/quickstart/responses/analyze_images_files_file_url.cs @@ -17,7 +17,7 @@ OpenAIFileClient files = new(key); OpenAIFile file = files.UploadFile(stream, "2024ltr.pdf", FileUploadPurpose.UserData); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("Analyze the letter and provide a summary of the key points."), ResponseContentPart.CreateInputFilePart(file.Id) diff --git a/docs/quickstart/responses/analyze_images_files_image_url.cs b/docs/quickstart/responses/analyze_images_files_image_url.cs index 07c8c8954..80f7bcc3b 100644 --- a/docs/quickstart/responses/analyze_images_files_image_url.cs +++ b/docs/quickstart/responses/analyze_images_files_image_url.cs @@ -10,7 +10,7 @@ string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!; OpenAIResponseClient client = new(model: "gpt-5", apiKey: key); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("What is in this image?"), ResponseContentPart.CreateInputImagePart(new Uri("https://openai-documentation.vercel.app/images/cat_and_otter.png")) diff --git a/docs/quickstart/responses/analyze_images_files_upload_file.cs b/docs/quickstart/responses/analyze_images_files_upload_file.cs index aff63a8ec..d6851f014 100644 --- a/docs/quickstart/responses/analyze_images_files_upload_file.cs +++ b/docs/quickstart/responses/analyze_images_files_upload_file.cs @@ -15,7 +15,7 @@ OpenAIFileClient files = new(key); OpenAIFile file = files.UploadFile("draconomicon.pdf", FileUploadPurpose.UserData); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputFilePart(file.Id), ResponseContentPart.CreateInputTextPart("What is the first dragon in the book?") diff --git a/docs/quickstart/responses/extend_model_with_tools_file_search.cs b/docs/quickstart/responses/extend_model_with_tools_file_search.cs index 8bc882eeb..8a995639f 100644 --- a/docs/quickstart/responses/extend_model_with_tools_file_search.cs +++ b/docs/quickstart/responses/extend_model_with_tools_file_search.cs @@ -14,7 +14,7 @@ ResponseCreationOptions options = new(); options.Tools.Add(ResponseTool.CreateFileSearchTool([ "" ])); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("What is deep research by OpenAI?") ]) diff --git a/docs/quickstart/responses/extend_model_with_tools_function_calling.cs b/docs/quickstart/responses/extend_model_with_tools_function_calling.cs index 3b7061a85..16dc027a5 100644 --- a/docs/quickstart/responses/extend_model_with_tools_function_calling.cs +++ b/docs/quickstart/responses/extend_model_with_tools_function_calling.cs @@ -34,7 +34,7 @@ ) ); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("What is the weather like in Paris today?") ]) diff --git a/docs/quickstart/responses/extend_model_with_tools_remote_mcp.cs b/docs/quickstart/responses/extend_model_with_tools_remote_mcp.cs index 8ebaaaec8..8a749eb28 100644 --- a/docs/quickstart/responses/extend_model_with_tools_remote_mcp.cs +++ b/docs/quickstart/responses/extend_model_with_tools_remote_mcp.cs @@ -18,7 +18,7 @@ toolCallApprovalPolicy: new McpToolCallApprovalPolicy(GlobalMcpToolCallApprovalPolicy.NeverRequireApproval) )); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("Roll 2d4+1") ]) diff --git a/docs/quickstart/responses/extend_model_with_tools_web_search.cs b/docs/quickstart/responses/extend_model_with_tools_web_search.cs index 8eb3a339a..51363908f 100644 --- a/docs/quickstart/responses/extend_model_with_tools_web_search.cs +++ b/docs/quickstart/responses/extend_model_with_tools_web_search.cs @@ -14,7 +14,7 @@ ResponseCreationOptions options = new(); options.Tools.Add(ResponseTool.CreateWebSearchTool()); -OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ +OpenAIResponse response = client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("What was a positive news story from today?") ])