{
  "openapi": "3.1.0",
  "info": {
    "title": "IO Intelligence",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.intelligence.io.solutions"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "oauth2",
        "flows": {}
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/api/r2r/v3/retrieval/agent": {
      "post": {
        "summary": "RAG-powered Conversational Agent",
        "description": "Engage with an intelligent agent for information retrieval, analysis, and research.",
        "operationId": "agent-based-query-resolution",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "Params": {
                    "type": "object",
                    "description": "Current message to process",
                    "required": [
                      "role"
                    ],
                    "properties": {
                      "role": {
                        "type": "string",
                        "description": "Or allowed string *",
                        "enum": [
                          "system",
                          "user",
                          "assistant",
                          "function",
                          "tool"
                        ]
                      },
                      "content": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "function_call": {
                        "type": "array"
                      },
                      "tool_calls": {
                        "type": "array"
                      },
                      "tool_call_id": {
                        "type": "string"
                      },
                      "metadata": {
                        "type": "array"
                      },
                      "structured_content": {
                        "type": "array"
                      },
                      "image_url": {
                        "type": "string"
                      },
                      "image_data": {
                        "type": "array"
                      }
                    }
                  },
                  "search_mode": {
                    "type": "string",
                    "description": "Pre-configured search modes: basic, advanced, or custom.",
                    "enum": [
                      "basic",
                      "advanced",
                      "custom"
                    ]
                  },
                  "search_settings": {
                    "type": "object",
                    "description": "The search configuration object for retrieving context.",
                    "properties": {
                      "use_hybrid_search": {
                        "type": "boolean",
                        "description": "Whether to perform a hybrid search. This is equivalent to setting use_semantic_search=True and use_fulltext_search=True, e.g. combining vector and keyword search.",
                        "default": false
                      },
                      "use_semantic_search": {
                        "type": "boolean",
                        "description": "Whether to use semantic search",
                        "default": true
                      },
                      "use_fulltext_search": {
                        "type": "boolean",
                        "description": "Whether to use full-text search",
                        "default": false
                      },
                      "filters": {
                        "type": "string",
                        "description": "Filters to apply to the search. Allowed operators include eq, neq, gt, gte, lt, lte, like, ilike, in, and nin.  Commonly seen filters include operations include the following:  {\"document_id\": {\"$eq\": \"9fbe403b-...\"}}  {\"document_id\": {\"$in\": [\"9fbe403b-...\", \"3e157b3a-...\"]}}  {\"collection_ids\": {\"$overlap\": [\"122fdf6a-...\", \"...\"]}}  {\"$and\": {\"$document_id\": ..., \"collection_ids\": ...}}"
                      },
                      "limit": {
                        "type": "integer",
                        "description": "Maximum number of results to return. >=1 <=1000",
                        "default": 10,
                        "format": "int32"
                      },
                      "offset": {
                        "type": "string",
                        "description": "Offset to paginate search results",
                        "default": "0"
                      },
                      "include_metadatas": {
                        "type": "boolean",
                        "description": "Whether to include element metadata in the search results",
                        "default": true
                      },
                      "include_scores": {
                        "type": "boolean",
                        "description": "Whether to include search score values in the search results",
                        "default": true
                      },
                      "search_strategy": {
                        "type": "string",
                        "description": "Search strategy to use (e.g., ‘vanilla’, ‘query_fusion’, ‘hyde’)",
                        "default": "vanilla"
                      },
                      "hybrid_settings": {
                        "type": "object",
                        "description": "Settings for hybrid search (only used if use_semantic_search and use_fulltext_search are both true)",
                        "properties": {
                          "full_text_weight": {
                            "type": "number",
                            "description": "Weight to apply to full text search",
                            "default": 1,
                            "format": "double"
                          },
                          "semantic_weight": {
                            "type": "number",
                            "description": "Weight to apply to semantic search",
                            "default": 5,
                            "format": "double"
                          },
                          "full_text_limit": {
                            "type": "integer",
                            "description": "Maximum number of results to return from full text search",
                            "default": 200,
                            "format": "int32"
                          },
                          "rrf_k": {
                            "type": "integer",
                            "description": "K-value for RRF (Rank Reciprocal Fusion)",
                            "default": 50,
                            "format": "int32"
                          }
                        }
                      },
                      "chunk_settings": {
                        "type": "object",
                        "description": "Settings specific to chunk/vector search",
                        "properties": {
                          "index_measure": {
                            "type": "string",
                            "description": "The distance measure to use for indexing",
                            "enum": [
                              "l2_distance",
                              "max_inner_product",
                              "cosine_distance",
                              "l1_distance",
                              "hamming_distance",
                              "jaccard_distance"
                            ]
                          },
                          "probes": {
                            "type": "integer",
                            "description": "Number of ivfflat index lists to query. Higher increases accuracy but decreases speed.",
                            "default": 10,
                            "format": "int32"
                          },
                          "ef_search": {
                            "type": "integer",
                            "description": "Size of the dynamic candidate list for HNSW index search. Higher increases accuracy but decreases speed.",
                            "default": 40,
                            "format": "int32"
                          },
                          "enabled": {
                            "type": "boolean",
                            "description": "Whether to enable chunk search",
                            "default": true
                          }
                        }
                      },
                      "graph_settings": {
                        "type": "object",
                        "description": "Settings specific to knowledge graph search",
                        "properties": {
                          "limits": {
                            "type": "array"
                          },
                          "enabled": {
                            "type": "boolean",
                            "description": "Whether to enable graph search",
                            "default": true
                          }
                        }
                      },
                      "num_sub_queries": {
                        "type": "integer",
                        "description": "Number of sub-queries/hypothetical docs to generate when using hyde or rag_fusion search strategies.",
                        "default": 5,
                        "format": "int32"
                      }
                    }
                  },
                  "rag_generation_config": {
                    "type": "object",
                    "description": "Configuration for RAG generation in 'rag' mode",
                    "properties": {
                      "model": {
                        "type": "string"
                      },
                      "temperature": {
                        "type": "number",
                        "format": "double"
                      },
                      "top_p": {
                        "type": "number",
                        "format": "double"
                      },
                      "max_tokens_to_sample": {
                        "type": "integer",
                        "format": "int32"
                      },
                      "stream": {
                        "type": "boolean"
                      },
                      "functions": {
                        "type": "array"
                      },
                      "tools": {
                        "type": "array"
                      },
                      "add_generation_kwargs": {
                        "type": "array"
                      },
                      "api_base": {
                        "type": "string"
                      },
                      "response_format": {
                        "type": "array",
                        "items": {
                          "properties": {
                            "Base Model": {
                              "type": "object"
                            }
                          },
                          "type": "object"
                        }
                      },
                      "extended_thinking": {
                        "type": "boolean",
                        "description": "Flag to enable extended thinking mode (for Anthropic providers)",
                        "default": false
                      },
                      "thinking_budget": {
                        "type": "integer",
                        "description": "Token budget for internal reasoning when extended thinking mode is enabled. Must be less than max_tokens_to_sample.",
                        "format": "int32"
                      },
                      "reasoning_effort": {
                        "type": "string",
                        "description": "Effort level for internal reasoning when extended thinking mode is enabled, low, medium, or high.Only applicable to OpenAI providers."
                      }
                    }
                  },
                  "research_generation_config": {
                    "type": "object",
                    "description": "Configuration for generation in ‘research’ mode. If not provided but mode=‘research’, rag_generation_config will be used with appropriate model overrides.",
                    "properties": {
                      "model": {
                        "type": "string"
                      },
                      "temperature": {
                        "type": "number",
                        "format": "double"
                      },
                      "top_p": {
                        "type": "number",
                        "format": "double"
                      },
                      "max_tokens_to_sample": {
                        "type": "integer",
                        "format": "int32"
                      },
                      "stream": {
                        "type": "boolean"
                      },
                      "functions": {
                        "type": "array"
                      },
                      "tools": {
                        "type": "array"
                      },
                      "add_generation_kwargs": {
                        "type": "array"
                      },
                      "api_base": {
                        "type": "string"
                      },
                      "response_format": {
                        "type": "array",
                        "items": {
                          "properties": {
                            "Base Model": {
                              "type": "object"
                            }
                          },
                          "type": "object"
                        }
                      },
                      "extended_thinking": {
                        "type": "boolean",
                        "description": "Flag to enable extended thinking mode (for Anthropic providers)",
                        "default": false
                      },
                      "thinking_budget": {
                        "type": "integer",
                        "description": "Token budget for internal reasoning when extended thinking mode is enabled. Must be less than max_tokens_to_sample.",
                        "format": "int32"
                      },
                      "reasoning_effort": {
                        "type": "string",
                        "description": "Effort level for internal reasoning when extended thinking mode is enabled, low, medium, or high.Only applicable to OpenAI providers."
                      }
                    }
                  },
                  "rag_tools": {
                    "type": "string",
                    "description": "List of tools to enable for RAG mode. Available tools: search_file_knowledge, get_file_content, web_search, web_scrape, search_file_descriptions",
                    "enum": [
                      "web_search",
                      "web_scrape",
                      "search_file_descriptions",
                      "search_file_knowledge",
                      "get_file_content"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": {
                      "results": {
                        "messages": [
                          {
                            "role": "assistant",
                            "content": "Aristotle (384–322 BC) was an Ancient\n                        Greek philosopher and polymath whose contributions\n                        have had a profound impact on various fields of\n                        knowledge.\n                        Here are some key points about his life and work:\n                        \n\n1. **Early Life**: Aristotle was born in 384 BC in\n                        Stagira, Chalcidice, which is near modern-day\n                        Thessaloniki, Greece. His father, Nicomachus, was the\n                        personal physician to King Amyntas of Macedon, which\n                        exposed Aristotle to medical and biological knowledge\n                        from a young age [C].\n\n2. **Education and Career**:\n                        After the death of his parents, Aristotle was sent to\n                        Athens to study at Plato's Academy, where he remained\n                        for about 20 years. After Plato's death, Aristotle\n                        left Athens and eventually became the tutor of\n                        Alexander the Great [C].\n                        \n\n3. **Philosophical Contributions**: Aristotle\n                        founded the Lyceum in Athens, where he established the\n                        Peripatetic school of philosophy. His works cover a\n                        wide range of subjects, including metaphysics, ethics,\n                        politics, logic, biology, and aesthetics. His writings\n                        laid the groundwork for many modern scientific and\n                        philosophical inquiries [A].\n\n4. **Legacy**:\n                        Aristotle's influence extends beyond philosophy to the\n                          natural sciences, linguistics, economics, and\n                          psychology. His method of systematic observation and\n                          analysis has been foundational to the development of\n                          modern science [A].\n\nAristotle's comprehensive\n                          approach to knowledge and his systematic methodology\n                          have earned him a lasting legacy as one of the\n                          greatest philosophers of all time.\n\nSources:\n                          \n- [A] Aristotle's broad range of writings and\n                          influence on modern science.\n- [C] Details about\n                          Aristotle's early life and education.",
                            "metadata": {
                              "aggregated_search_results": {
                                "chunk_search_results": [
                                  {
                                    "document_id": "3e157b3a-8469-51db-90d9-52e7d896b49b",
                                    "id": "3f3d47f3-8baf-58eb-8bc2-0171fb1c6e09",
                                    "metadata": {
                                      "associated_query": "What is the capital of France?",
                                      "title": "example_document.pdf"
                                    },
                                    "owner_id": "2acb499e-8428-543b-bd85-0d9098718220",
                                    "score": 0.23943702876567796,
                                    "text": "Example text from the document"
                                  }
                                ],
                                "document_search_results": [
                                  {
                                    "document": {
                                      "chunks": [
                                        "Chunk 1",
                                        "Chunk 2"
                                      ],
                                      "id": "3f3d47f3-8baf-58eb-8bc2-0171fb1c6e09",
                                      "metadata": {},
                                      "title": "Document Title"
                                    }
                                  }
                                ],
                                "graph_search_results": [
                                  {
                                    "chunk_ids": [
                                      "c68dc72e-fc23-5452-8f49-d7bd46088a96"
                                    ],
                                    "content": {
                                      "description": "Entity Description",
                                      "id": "3f3d47f3-8baf-58eb-8bc2-0171fb1c6e09",
                                      "metadata": {},
                                      "name": "Entity Name"
                                    },
                                    "metadata": {
                                      "associated_query": "What is the capital of France?"
                                    },
                                    "result_type": "entity"
                                  }
                                ],
                                "web_search_results": [
                                  {
                                    "date": "2021-01-01",
                                    "link": "https://example.com/page",
                                    "position": 1,
                                    "sitelinks": [
                                      {
                                        "link": "https://example.com/sitelink",
                                        "title": "Sitelink Title"
                                      }
                                    ],
                                    "snippet": "Page snippet",
                                    "title": "Page Title"
                                  }
                                ]
                              },
                              "citations": [
                                {
                                  "collection_ids": [
                                    "122fdf6a-e116-546b-a8f6-e4cb2e2c0a09"
                                  ],
                                  "document_id": "\n                                    e43864f5-a36f-548e-aacd-6f8d48b30c7f\n                                    ",
                                  "endIndex": 396,
                                  "id": "e760bb76-1c6e-52eb-910d-0ce5b567011b",
                                  "index": 1,
                                  "metadata": {
                                    "chunk_order": 68,
                                    "document_type": "pdf",
                                    "license": "CC-BY-4.0",
                                    "title": "DeepSeek_R1.pdf"
                                  },
                                  "owner_id": "\n                                    2acb499e-8428-543b-bd85-0d9098718220\n                                    ",
                                  "rawIndex": 9,
                                  "score": 0.64,
                                  "snippetEndIndex": 418,
                                  "snippetStartIndex": 320,
                                  "sourceType": "chunk",
                                  "startIndex": 393,
                                  "text": "\n                                    Document Title: DeepSeek_R1.pdf\n                                    \n\nText: could achieve an accuracy of ...\n                                    "
                                }
                              ]
                            }
                          }
                        ],
                        "conversation_id": "a32b4c5d-6e7f-8a9b-0c1d-2e3f4a5b6c7d"
                      }
                    }
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": {
                      "type": "object",
                      "properties": {
                        "messages": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "role": {
                                "type": "string",
                                "example": "assistant"
                              },
                              "content": {
                                "type": "string",
                                "example": "Aristotle (384–322 BC) was an Ancient\n                        Greek philosopher and polymath whose contributions\n                        have had a profound impact on various fields of\n                        knowledge.\n                        Here are some key points about his life and work:\n                        \n\n1. **Early Life**: Aristotle was born in 384 BC in\n                        Stagira, Chalcidice, which is near modern-day\n                        Thessaloniki, Greece. His father, Nicomachus, was the\n                        personal physician to King Amyntas of Macedon, which\n                        exposed Aristotle to medical and biological knowledge\n                        from a young age [C].\n\n2. **Education and Career**:\n                        After the death of his parents, Aristotle was sent to\n                        Athens to study at Plato's Academy, where he remained\n                        for about 20 years. After Plato's death, Aristotle\n                        left Athens and eventually became the tutor of\n                        Alexander the Great [C].\n                        \n\n3. **Philosophical Contributions**: Aristotle\n                        founded the Lyceum in Athens, where he established the\n                        Peripatetic school of philosophy. His works cover a\n                        wide range of subjects, including metaphysics, ethics,\n                        politics, logic, biology, and aesthetics. His writings\n                        laid the groundwork for many modern scientific and\n                        philosophical inquiries [A].\n\n4. **Legacy**:\n                        Aristotle's influence extends beyond philosophy to the\n                          natural sciences, linguistics, economics, and\n                          psychology. His method of systematic observation and\n                          analysis has been foundational to the development of\n                          modern science [A].\n\nAristotle's comprehensive\n                          approach to knowledge and his systematic methodology\n                          have earned him a lasting legacy as one of the\n                          greatest philosophers of all time.\n\nSources:\n                          \n- [A] Aristotle's broad range of writings and\n                          influence on modern science.\n- [C] Details about\n                          Aristotle's early life and education."
                              },
                              "metadata": {
                                "type": "object",
                                "properties": {
                                  "aggregated_search_results": {
                                    "type": "object",
                                    "properties": {
                                      "chunk_search_results": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "document_id": {
                                              "type": "string",
                                              "example": "3e157b3a-8469-51db-90d9-52e7d896b49b"
                                            },
                                            "id": {
                                              "type": "string",
                                              "example": "3f3d47f3-8baf-58eb-8bc2-0171fb1c6e09"
                                            },
                                            "metadata": {
                                              "type": "object",
                                              "properties": {
                                                "associated_query": {
                                                  "type": "string",
                                                  "example": "What is the capital of France?"
                                                },
                                                "title": {
                                                  "type": "string",
                                                  "example": "example_document.pdf"
                                                }
                                              }
                                            },
                                            "owner_id": {
                                              "type": "string",
                                              "example": "2acb499e-8428-543b-bd85-0d9098718220"
                                            },
                                            "score": {
                                              "type": "number",
                                              "example": 0.23943702876567796,
                                              "default": 0
                                            },
                                            "text": {
                                              "type": "string",
                                              "example": "Example text from the document"
                                            }
                                          }
                                        }
                                      },
                                      "document_search_results": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "document": {
                                              "type": "object",
                                              "properties": {
                                                "chunks": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "string",
                                                    "example": "Chunk 1"
                                                  }
                                                },
                                                "id": {
                                                  "type": "string",
                                                  "example": "3f3d47f3-8baf-58eb-8bc2-0171fb1c6e09"
                                                },
                                                "metadata": {
                                                  "type": "object",
                                                  "properties": {}
                                                },
                                                "title": {
                                                  "type": "string",
                                                  "example": "Document Title"
                                                }
                                              }
                                            }
                                          }
                                        }
                                      },
                                      "graph_search_results": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "chunk_ids": {
                                              "type": "array",
                                              "items": {
                                                "type": "string",
                                                "example": "c68dc72e-fc23-5452-8f49-d7bd46088a96"
                                              }
                                            },
                                            "content": {
                                              "type": "object",
                                              "properties": {
                                                "description": {
                                                  "type": "string",
                                                  "example": "Entity Description"
                                                },
                                                "id": {
                                                  "type": "string",
                                                  "example": "3f3d47f3-8baf-58eb-8bc2-0171fb1c6e09"
                                                },
                                                "metadata": {
                                                  "type": "object",
                                                  "properties": {}
                                                },
                                                "name": {
                                                  "type": "string",
                                                  "example": "Entity Name"
                                                }
                                              }
                                            },
                                            "metadata": {
                                              "type": "object",
                                              "properties": {
                                                "associated_query": {
                                                  "type": "string",
                                                  "example": "What is the capital of France?"
                                                }
                                              }
                                            },
                                            "result_type": {
                                              "type": "string",
                                              "example": "entity"
                                            }
                                          }
                                        }
                                      },
                                      "web_search_results": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "date": {
                                              "type": "string",
                                              "example": "2021-01-01"
                                            },
                                            "link": {
                                              "type": "string",
                                              "example": "https://example.com/page"
                                            },
                                            "position": {
                                              "type": "integer",
                                              "example": 1,
                                              "default": 0
                                            },
                                            "sitelinks": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "link": {
                                                    "type": "string",
                                                    "example": "https://example.com/sitelink"
                                                  },
                                                  "title": {
                                                    "type": "string",
                                                    "example": "Sitelink Title"
                                                  }
                                                }
                                              }
                                            },
                                            "snippet": {
                                              "type": "string",
                                              "example": "Page snippet"
                                            },
                                            "title": {
                                              "type": "string",
                                              "example": "Page Title"
                                            }
                                          }
                                        }
                                      }
                                    }
                                  },
                                  "citations": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "collection_ids": {
                                          "type": "array",
                                          "items": {
                                            "type": "string",
                                            "example": "122fdf6a-e116-546b-a8f6-e4cb2e2c0a09"
                                          }
                                        },
                                        "document_id": {
                                          "type": "string",
                                          "example": "\n                                    e43864f5-a36f-548e-aacd-6f8d48b30c7f\n                                    "
                                        },
                                        "endIndex": {
                                          "type": "integer",
                                          "example": 396,
                                          "default": 0
                                        },
                                        "id": {
                                          "type": "string",
                                          "example": "e760bb76-1c6e-52eb-910d-0ce5b567011b"
                                        },
                                        "index": {
                                          "type": "integer",
                                          "example": 1,
                                          "default": 0
                                        },
                                        "metadata": {
                                          "type": "object",
                                          "properties": {
                                            "chunk_order": {
                                              "type": "integer",
                                              "example": 68,
                                              "default": 0
                                            },
                                            "document_type": {
                                              "type": "string",
                                              "example": "pdf"
                                            },
                                            "license": {
                                              "type": "string",
                                              "example": "CC-BY-4.0"
                                            },
                                            "title": {
                                              "type": "string",
                                              "example": "DeepSeek_R1.pdf"
                                            }
                                          }
                                        },
                                        "owner_id": {
                                          "type": "string",
                                          "example": "\n                                    2acb499e-8428-543b-bd85-0d9098718220\n                                    "
                                        },
                                        "rawIndex": {
                                          "type": "integer",
                                          "example": 9,
                                          "default": 0
                                        },
                                        "score": {
                                          "type": "number",
                                          "example": 0.64,
                                          "default": 0
                                        },
                                        "snippetEndIndex": {
                                          "type": "integer",
                                          "example": 418,
                                          "default": 0
                                        },
                                        "snippetStartIndex": {
                                          "type": "integer",
                                          "example": 320,
                                          "default": 0
                                        },
                                        "sourceType": {
                                          "type": "string",
                                          "example": "chunk"
                                        },
                                        "startIndex": {
                                          "type": "integer",
                                          "example": 393,
                                          "default": 0
                                        },
                                        "text": {
                                          "type": "string",
                                          "example": "\n                                    Document Title: DeepSeek_R1.pdf\n                                    \n\nText: could achieve an accuracy of ...\n                                    "
                                        }
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        },
                        "conversation_id": {
                          "type": "string",
                          "example": "a32b4c5d-6e7f-8a9b-0c1d-2e3f4a5b6c7d"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "404",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": {}
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "422": {
            "description": "422",
            "content": {
              "text/plain": {
                "examples": {
                  "Result": {
                    "value": {}
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          }
        },
        "deprecated": false,
        "x-readme": {
          "code-samples": [
            {
              "language": "curl",
              "code": "curl -X POST https://api.intelligence.io.solutions/api/r2r/v3/retrieval/agent \\\n     -H \"Authorization: Bearer $IOINTELLIGENCE_API_KEY\" \\\n     -H \"Content-Type: application/json\" \\\n     -d '{}'"
            },
            {
              "language": "python",
              "code": "from r2r import (\n    R2RClient,\n    ThinkingEvent,\n    ToolCallEvent,\n    ToolResultEvent,\n    CitationEvent,\n    FinalAnswerEvent,\n    MessageEvent,\n)\n\nclient = R2RClient()\n# when using auth, do client.login(...)\n\n# Basic synchronous request\nresponse = client.retrieval.agent(\n    message={\n        \"role\": \"user\",\n        \"content\": \"Do a deep analysis of the philosophical implications of DeepSeek R1\"\n    },\n    rag_tools=[\"web_search\", \"web_scrape\", \"search_file_descriptions\", \"search_file_knowledge\", \"get_file_content\"],\n)\n\n# Advanced analysis with streaming and extended thinking\nstreaming_response = client.retrieval.agent(\n    message={\n        \"role\": \"user\",\n        \"content\": \"Do a deep analysis of the philosophical implications of DeepSeek R1\"\n    },\n    search_settings={\"limit\": 20},\n    rag_tools=[\"web_search\", \"web_scrape\", \"search_file_descriptions\", \"search_file_knowledge\", \"get_file_content\"],\n    rag_generation_config={\n        \"model\": \"anthropic/claude-3-7-sonnet-20250219\",\n        \"extended_thinking\": True,\n        \"thinking_budget\": 4096,\n        \"temperature\": 1,\n        \"top_p\": None,\n        \"max_tokens\": 16000,\n        \"stream\": True\n    }\n)\n\n# Process streaming events with emoji only on type change\ncurrent_event_type = None\nfor event in streaming_response:\n    # Check if the event type has changed\n    event_type = type(event)\n    if event_type != current_event_type:\n        current_event_type = event_type\n        print() # Add newline before new event type\n\n        # Print emoji based on the new event type\n        if isinstance(event, ThinkingEvent):\n            print(f\"\n🧠 Thinking: \", end=\"\", flush=True)\n        elif isinstance(event, ToolCallEvent):\n            print(f\"\n🔧 Tool call: \", end=\"\", flush=True)\n        elif isinstance(event, ToolResultEvent):\n            print(f\"\n📊 Tool result: \", end=\"\", flush=True)\n        elif isinstance(event, CitationEvent):\n            print(f\"\n📑 Citation: \", end=\"\", flush=True)\n        elif isinstance(event, MessageEvent):\n            print(f\"\n💬 Message: \", end=\"\", flush=True)\n        elif isinstance(event, FinalAnswerEvent):\n            print(f\"\n✅ Final answer: \", end=\"\", flush=True)\n\n    # Print the content without the emoji\n    if isinstance(event, ThinkingEvent):\n        print(f\"{event.data.delta.content[0].payload.value}\", end=\"\", flush=True)\n    elif isinstance(event, ToolCallEvent):\n        print(f\"{event.data.name}({event.data.arguments})\")\n    elif isinstance(event, ToolResultEvent):\n        print(f\"{event.data.content[:60]}...\")\n    elif isinstance(event, CitationEvent):\n        print(f\"{event.data.id}\")\n    elif isinstance(event, MessageEvent):\n        print(f\"{event.data.delta.content[0].payload.value}\", end=\"\", flush=True)\n    elif isinstance(event, FinalAnswerEvent):\n        print(f\"{event.data.generated_answer[:100]}...\")\n        print(f\"   Citations: {len(event.data.citations)} sources referenced\")\n\n# Conversation with multiple turns (synchronous)\nconversation = client.conversations.create()\n\n# First message in conversation\nresults_1 = client.retrieval.agent(\n    message={\"role\": \"user\", \"content\": \"What does DeepSeek R1 imply for the future of AI?\"},\n    rag_generation_config={\n        \"model\": \"anthropic/claude-3-7-sonnet-20250219\",\n        \"extended_thinking\": True,\n        \"thinking_budget\": 4096,\n        \"temperature\": 1,\n        \"top_p\": None,\n        \"max_tokens\": 16000,\n        \"stream\": False\n    },\n    conversation_id=conversation.results.id\n)\n\n# Follow-up query in the same conversation\nresults_2 = client.retrieval.agent(\n    message={\"role\": \"user\", \"content\": \"How does it compare to other reasoning models?\"},\n    rag_generation_config={\n        \"model\": \"anthropic/claude-3-7-sonnet-20250219\",\n        \"extended_thinking\": True,\n        \"thinking_budget\": 4096,\n        \"temperature\": 1,\n        \"top_p\": None,\n        \"max_tokens\": 16000,\n        \"stream\": False\n    },\n    conversation_id=conversation.results.id\n)\n\n# Access the final results\nprint(f\"First response: {results_1.generated_answer[:100]}...\")\nprint(f\"Follow-up response: {results_2.generated_answer[:100]}...\")\n"
            }
          ],
          "samples-languages": [
            "curl",
            "python"
          ]
        }
      }
    }
  }
}