SpyBara
Go Premium

Documentation 2026-11-02 23:58 UTC to 2026-11-03 22:58 UTC

10 files changed +98 −38. View all changes and history on the product overview
2026
Fri 13 23:58 Thu 12 22:57 Wed 11 23:57 Tue 10 23:02 Mon 9 23:02 Sun 8 22:59 Sat 7 22:59 Fri 6 23:00 Thu 5 23:00 Wed 4 22:58 Tue 3 22:58 Mon 2 23:58 Sun 1 23:00
Details

144{144{

145 ResponseModalities = ChatResponseModalities.Text | ChatResponseModalities.Audio,145 ResponseModalities = ChatResponseModalities.Text | ChatResponseModalities.Audio,

146 AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Wav),146 AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Wav),

147 StoredOutputEnabled = true,147 StoredOutputEnabled = false,

148};148};

149 149 

150ChatCompletion completion = await client.CompleteChatAsync(150ChatCompletion completion = await client.CompleteChatAsync(


400{400{

401 ResponseModalities = ChatResponseModalities.Text | ChatResponseModalities.Audio,401 ResponseModalities = ChatResponseModalities.Text | ChatResponseModalities.Audio,

402 AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Wav),402 AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Wav),

403 StoredOutputEnabled = true,403 StoredOutputEnabled = false,

404};404};

405 405 

406ChatCompletion completion = await client.CompleteChatAsync([message], options);406ChatCompletion completion = await client.CompleteChatAsync([message], options);

Details

271 ResponseItem.CreateUserMessageItem("Write a very long novel about otters in space.")271 ResponseItem.CreateUserMessageItem("Write a very long novel about otters in space.")

272);272);

273 273 

274ResponseResult created = await client.CreateResponseAsync(options);274ResponseResult response = await client.CreateResponseAsync(options);

275ResponseResult response = await client.GetResponseAsync(created.Id);

276while (response.Status is ResponseStatus.Queued or ResponseStatus.InProgress)275while (response.Status is ResponseStatus.Queued or ResponseStatus.InProgress)

277{276{

278 await Task.Delay(TimeSpan.FromSeconds(1));277 await Task.Delay(TimeSpan.FromSeconds(1));

Details

503OpenAIEmbedding embedding = await client.GenerateEmbeddingAsync("Testing 123");503OpenAIEmbedding embedding = await client.GenerateEmbeddingAsync("Testing 123");

504 504 

505float[] shortened = embedding.ToFloats().Span[..256].ToArray();505float[] shortened = embedding.ToFloats().Span[..256].ToArray();

506double magnitude = Math.Sqrt(shortened.Sum(value => value * value));506double magnitude = Math.Sqrt(shortened.Sum(value => (double)value * value));

507float[] normalized =507double[] normalized =

508 magnitude == 0508 magnitude == 0

509 ? shortened509 ? shortened.Select(value => (double)value).ToArray()

510 : shortened.Select(value => (float)(value / magnitude)).ToArray();510 : shortened.Select(value => value / magnitude).ToArray();

511 511 

512Console.WriteLine($"Dimensions: {normalized.Length}");512Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(normalized));

513Console.WriteLine($"First value: {normalized[0]:F6}");

514Console.WriteLine(

515 $"L2 norm: {Math.Sqrt(normalized.Sum(value => value * value)):F3}"

516);

517```513```

518 514 

519```ruby515```ruby


927 double dot = 0, leftNorm = 0, rightNorm = 0;923 double dot = 0, leftNorm = 0, rightNorm = 0;

928 for (int i = 0; i < left.Length; i++)924 for (int i = 0; i < left.Length; i++)

929 {925 {

930 dot += left[i] * right[i];926 dot += (double)left[i] * right[i];

931 leftNorm += left[i] * left[i];927 leftNorm += (double)left[i] * left[i];

932 rightNorm += right[i] * right[i];928 rightNorm += (double)right[i] * right[i];

933 }929 }

934 return dot / Math.Sqrt(leftNorm * rightNorm);930 return dot / Math.Sqrt(leftNorm * rightNorm);

935}931}


1188 double dot = 0, leftNorm = 0, rightNorm = 0;1184 double dot = 0, leftNorm = 0, rightNorm = 0;

1189 for (int i = 0; i < left.Length; i++)1185 for (int i = 0; i < left.Length; i++)

1190 {1186 {

1191 dot += left[i] * right[i];1187 dot += (double)left[i] * right[i];

1192 leftNorm += left[i] * left[i];1188 leftNorm += (double)left[i] * left[i];

1193 rightNorm += right[i] * right[i];1189 rightNorm += (double)right[i] * right[i];

1194 }1190 }

1195 return dot / Math.Sqrt(leftNorm * rightNorm);1191 return dot / Math.Sqrt(leftNorm * rightNorm);

1196}1192}


1458 double dot = 0, leftNorm = 0, rightNorm = 0;1454 double dot = 0, leftNorm = 0, rightNorm = 0;

1459 for (int i = 0; i < left.Length; i++)1455 for (int i = 0; i < left.Length; i++)

1460 {1456 {

1461 dot += left[i] * right[i];1457 dot += (double)left[i] * right[i];

1462 leftNorm += left[i] * left[i];1458 leftNorm += (double)left[i] * left[i];

1463 rightNorm += right[i] * right[i];1459 rightNorm += (double)right[i] * right[i];

1464 }1460 }

1465 return dot / Math.Sqrt(leftNorm * rightNorm);1461 return dot / Math.Sqrt(leftNorm * rightNorm);

1466}1462}


1800 double dot = 0, leftNorm = 0, rightNorm = 0;1796 double dot = 0, leftNorm = 0, rightNorm = 0;

1801 for (int i = 0; i < left.Length; i++)1797 for (int i = 0; i < left.Length; i++)

1802 {1798 {

1803 dot += left[i] * right[i];1799 dot += (double)left[i] * right[i];

1804 leftNorm += left[i] * left[i];1800 leftNorm += (double)left[i] * left[i];

1805 rightNorm += right[i] * right[i];1801 rightNorm += (double)right[i] * right[i];

1806 }1802 }

1807 return dot / Math.Sqrt(leftNorm * rightNorm);1803 return dot / Math.Sqrt(leftNorm * rightNorm);

1808}1804}

Details

3262 },3262 },

3263 "additionalProperties": {3263 "additionalProperties": {

3264 "type": "boolean"3264 "type": "boolean"

3265 },

3266 "$defs": {

3267 "type": "object",

3268 "additionalProperties": {

3269 "$ref": "#/$defs/schema_definition"

3270 }

3265 }3271 }

3266 },3272 },

3267 "required": [3273 "required": [


3284 "schema_definition": {3290 "schema_definition": {

3285 "type": "object",3291 "type": "object",

3286 "properties": {3292 "properties": {

3293 "description": {

3294 "type": "string"

3295 },

3296 "enum": {

3297 "type": "array"

3298 },

3287 "type": {3299 "type": {

3288 "type": "string",3300 "type": "string",

3289 "enum": [3301 "enum": [


3322 },3334 },

3323 "additionalProperties": {3335 "additionalProperties": {

3324 "type": "boolean"3336 "type": "boolean"

3337 },

3338 "$ref": {

3339 "type": "string"

3340 },

3341 "anyOf": {

3342 "type": "array",

3343 "items": {

3344 "$ref": "#/$defs/schema_definition"

3345 }

3325 }3346 }

3326 },3347 },

3327 "required": [

3328 "type"

3329 ],

3330 "additionalProperties": false,3348 "additionalProperties": false,

3331 "if": {3349 "if": {

3332 "properties": {3350 "properties": {

3333 "type": {3351 "type": {

3334 "const": "object"3352 "const": "object"

3335 }3353 }

3336 }3354 },

3355 "required": [

3356 "type"

3357 ]

3337 },3358 },

3338 "then": {3359 "then": {

3339 "required": [3360 "required": [

3340 "properties"3361 "properties"

3341 ]3362 ]

3363 },

3364 "anyOf": [

3365 {

3366 "required": [

3367 "$ref"

3368 ]

3369 },

3370 {

3371 "required": [

3372 "type"

3373 ]

3374 },

3375 {

3376 "required": [

3377 "anyOf"

3378 ]

3342 }3379 }

3380 ]

3343 }3381 }

3344 }3382 }

3345 }3383 }


4744 "schema_definition": {4782 "schema_definition": {

4745 "type": "object",4783 "type": "object",

4746 "properties": {4784 "properties": {

4785 "description": { "type": "string" },

4786 "enum": { "type": "array" },

4747 "type": {4787 "type": {

4748 "type": "string",4788 "type": "string",

4749 "enum": [4789 "enum": [

Details

1835RealtimeResponseOptions options = new()1835RealtimeResponseOptions options = new()

1836 1836 

1837{1837{

1838 OutputModalities = { RealtimeOutputModality.Text },

1838 Instructions = "Say exactly the following: I'm a little teapot, short and stout! This is my handle, this is my spout!"1839 Instructions = "Say exactly the following: I'm a little teapot, short and stout! This is my handle, this is my spout!"

1839 1840 

1840};1841};

Details

356 {356 {

357 ResponseOptions = new()357 ResponseOptions = new()

358 {358 {

359 OutputModalities = { RealtimeOutputModality.Text },

359 Metadata = new Dictionary<string, BinaryData> { ["topic"] = BinaryData.FromObjectAsJson("lookup_order_followup") },360 Metadata = new Dictionary<string, BinaryData> { ["topic"] = BinaryData.FromObjectAsJson("lookup_order_followup") },

360 ToolChoice = RealtimeDefaultToolChoice.None361 ToolChoice = RealtimeDefaultToolChoice.None

361 }362 }


1103```1104```

1104 1105 

1105```csharp1106```csharp

1107using System.Text.Json;

1106using OpenAI.Realtime;1108using OpenAI.Realtime;

1107 1109 

1108#pragma warning disable OPENAI0021110#pragma warning disable OPENAI002

1109// Replace https://mcp.example.com/mcp with your company's MCP server URL.1111// Connect to the official OpenAI documentation MCP server.

1110 1112 

1111internal static async Task ApproveMcpRequestAsync(RealtimeSessionClient session, string approvalRequestId, CancellationToken cancellationToken)1113internal static async Task ApproveMcpRequestAsync(RealtimeSessionClient session, string approvalRequestId, CancellationToken cancellationToken)

1112{1114{

1113 await session.SendCommandAsync(new RealtimeClientCommandConversationItemCreate(new RealtimeMcpToolCallApprovalResponseItem(approvalRequestId, true)1115 await session.SendCommandAsync(new RealtimeClientCommandConversationItemCreate(new RealtimeMcpToolCallApprovalResponseItem(approvalRequestId, true)

1114 {1116 {

1115 Id = $"mcp_approval_{approvalRequestId}"1117 Id = Guid.NewGuid().ToString("N")

1116 }), cancellationToken);1118 }), cancellationToken);

1117}1119}

1118```1120```


1285```1287```

1286 1288 

1287```csharp1289```csharp

1290using System.Text.Json;

1288using OpenAI.Realtime;1291using OpenAI.Realtime;

1289 1292 

1290#pragma warning disable OPENAI0021293#pragma warning disable OPENAI002


1294 ResponseOptions = new()1297 ResponseOptions = new()

1295 {1298 {

1296 Metadata = new Dictionary<string, BinaryData> { ["topic"] = BinaryData.FromObjectAsJson("mcp_initial") },1299 Metadata = new Dictionary<string, BinaryData> { ["topic"] = BinaryData.FromObjectAsJson("mcp_initial") },

1300 ToolChoice = RealtimeDefaultToolChoice.Required,

1297 OutputModalities =1301 OutputModalities =

1298 {1302 {

1299 RealtimeOutputModality.Text1303 RealtimeOutputModality.Text

Details

1403 "properties": {1403 "properties": {

1404 "type": { "type": "string", "enum": ["div", "button", "header", "section", "field", "form"] },1404 "type": { "type": "string", "enum": ["div", "button", "header", "section", "field", "form"] },

1405 "label": { "type": "string" },1405 "label": { "type": "string" },

1406 "children": { "type": "array", "items": { "$ref": "#/$defs/component" } },

1407 "attributes": {1406 "attributes": {

1408 "type": "array",1407 "type": "array",

1409 "items": {1408 "items": {


1412 "required": ["name", "value"],1411 "required": ["name", "value"],

1413 "additionalProperties": false1412 "additionalProperties": false

1414 }1413 }

1415 }1414 },

1415 "children": { "type": "array", "items": { "$ref": "#/$defs/component" } }

1416 },1416 },

1417 "required": ["type", "label", "children", "attributes"],1417 "required": ["type", "label", "children", "attributes"],

1418 "additionalProperties": false1418 "additionalProperties": false


1424CreateResponseOptions options = new()1424CreateResponseOptions options = new()

1425{1425{

1426 Model = "gpt-6-astra",1426 Model = "gpt-6-astra",

1427 MaxOutputTokenCount = 4096,

1427 TextOptions = new ResponseTextOptions1428 TextOptions = new ResponseTextOptions

1428 {1429 {

1429 TextFormat = ResponseTextFormat.CreateJsonSchemaFormat(1430 TextFormat = ResponseTextFormat.CreateJsonSchemaFormat(


1434 },1435 },

1435};1436};

1436options.InputItems.Add(ResponseItem.CreateSystemMessageItem("You are a UI generator. Convert the user request into a component tree."));1437options.InputItems.Add(ResponseItem.CreateSystemMessageItem("You are a UI generator. Convert the user request into a component tree."));

1437options.InputItems.Add(ResponseItem.CreateUserMessageItem("Make a User Profile Form"));1438options.InputItems.Add(ResponseItem.CreateUserMessageItem(

1439 "Make a small user profile form with exactly three direct children: " +

1440 "a Name field, an Email field, and a Save button. Give each child no children. " +

1441 "Use short labels and at most two short attributes per component."

1442));

1438 1443 

1439ResponseResult response = await client.CreateResponseAsync(options);1444ResponseResult response = await client.CreateResponseAsync(options);

1440using JsonDocument parsed = JsonDocument.Parse(response.GetOutputText());1445string text = response.GetOutputText();

1446bool refused = response.OutputItems.OfType<MessageResponseItem>()

1447 .SelectMany(message => message.Content)

1448 .Any(part => part.Kind == ResponseContentPartKind.Refusal);

1449if (response.Status != ResponseStatus.Completed || refused || string.IsNullOrWhiteSpace(text))

1450{

1451 throw new InvalidOperationException("UI generation did not complete.");

1452}

1453using JsonDocument parsed = JsonDocument.Parse(text);

1441Console.WriteLine(parsed.RootElement);1454Console.WriteLine(parsed.RootElement);

1442```1455```

1443 1456 

Details

683string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;683string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;

684ResponsesClient client = new(key);684ResponsesClient client = new(key);

685 685 

686CreateResponseOptions options = new() { Model = "gpt-6-astra" };686CreateResponseOptions options = new()

687{

688 Model = "gpt-6-astra",

689 ToolChoice = ResponseToolChoice.CreateRequiredChoice(),

690 ParallelToolCallsEnabled = false

691};

687options.Tools.Add(692options.Tools.Add(

688 ResponseTool.CreateMcpTool(693 ResponseTool.CreateMcpTool(

689 serverLabel: "openai_docs",694 serverLabel: "openai_docs",

690 serverUri: new Uri("https://developers.openai.com/mcp"),695 serverUri: new Uri("https://developers.openai.com/mcp"),

696 allowedTools: new McpToolFilter { ToolNames = { "search_openai_docs" } },

691 toolCallApprovalPolicy: DefaultMcpToolCallApprovalPolicy.AlwaysRequireApproval697 toolCallApprovalPolicy: DefaultMcpToolCallApprovalPolicy.AlwaysRequireApproval

692 )698 )

693);699);


701 707 

702// Step 2: Approve the tool call and get the final response.708// Step 2: Approve the tool call and get the final response.

703options.PreviousResponseId = response1.Id;709options.PreviousResponseId = response1.Id;

710options.ToolChoice = ResponseToolChoice.CreateNoneChoice();

704options.InputItems.Clear();711options.InputItems.Clear();

705options.InputItems.Add(712options.InputItems.Add(

706 ResponseItem.CreateMcpApprovalResponseItem(approvalRequest.Id, approved: true)713 ResponseItem.CreateMcpApprovalResponseItem(approvalRequest.Id, approved: true)

libraries.md +1 −1

Details

173<dependency>173<dependency>

174 <groupId>com.openai</groupId>174 <groupId>com.openai</groupId>

175 <artifactId>openai-java</artifactId>175 <artifactId>openai-java</artifactId>

176 <version>4.96.0</version>176 <version>4.98.0</version>

177</dependency>177</dependency>

178```178```

179 179 

quickstart.md +1 −1

Details

190<dependency>190<dependency>

191 <groupId>com.openai</groupId>191 <groupId>com.openai</groupId>

192 <artifactId>openai-java</artifactId>192 <artifactId>openai-java</artifactId>

193 <version>4.96.0</version>193 <version>4.98.0</version>

194</dependency>194</dependency>

195```195```

196 196