{"id":10925,"date":"2025-10-20T05:00:18","date_gmt":"2025-10-20T12:00:18","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cosmosdb\/?p=10925"},"modified":"2025-10-20T11:02:32","modified_gmt":"2025-10-20T18:02:32","slug":"announcing-latest-azure-cosmos-db-python-sdk-powering-the-future-of-ai-with-openai","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cosmosdb\/announcing-latest-azure-cosmos-db-python-sdk-powering-the-future-of-ai-with-openai\/","title":{"rendered":"Announcing latest Azure Cosmos DB Python SDK: Powering the Future of AI with OpenAI"},"content":{"rendered":"<p class=\"code-line\" dir=\"auto\" data-line=\"2\">We&#8217;re thrilled to announce the stable release of Azure Cosmos DB Python SDK version 4.14.0! This release brings together months of innovation and collaboration, featuring ground-breaking capabilities that have been battle-tested in production environments. Many of these features were developed in close partnership with <strong>OpenAI<\/strong>, who rely heavily on Cosmos DB to store chat data for ChatGPT at massive scale.<\/p>\n<h2 id=\"what-makes-this-release-special\" class=\"code-line\" dir=\"auto\" data-line=\"4\">What Makes This Release Special<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"6\">After extensive beta testing, we&#8217;re proud to deliver a stable release that combines performance, intelligence, and developer productivity. The features in this release have been proven in real-world scenarios, including powering some of the most demanding AI workloads in the world.<\/p>\n<h2 id=\"%F0%9F%9A%80-major-new-features\" class=\"code-line\" dir=\"auto\" data-line=\"8\">\ud83d\ude80 Major New Features<\/h2>\n<h3 id=\"semantic-reranking---ai-powered-document-intelligence-preview\" class=\"code-line\" dir=\"auto\" data-line=\"10\">Semantic Reranking &#8211; AI powered document intelligence (Preview)<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"12\">One of the most exciting additions is our new\u00a0<strong>Semantic Reranking API<\/strong>, currently a <strong>private preview<\/strong> feature that brings AI-powered document reranking directly to your Cosmos DB containers. This feature leverages Azure&#8217;s inference services to intelligently rank documents based on semantic relevance. If you want to be onboarded to the semantic re-ranking private preview &#8211; sign up <a href=\"https:\/\/aka.ms\/AzureCosmosDB\/RerankerPreview\" target=\"_blank\" rel=\"noopener\">here<\/a>. For more information, contact us at <a href=\"mailto:CosmosDBSemanticReranker@Microsoft.com\" target=\"_blank\" rel=\"noopener\">CosmosDBSemanticReranker@Microsoft.com<\/a>. Check out our demo sample <a href=\"https:\/\/github.com\/microsoft\/AzureDataRetrievalAugmentedGenerationSamples\/tree\/main\/Python\/CosmosDB-NoSQL_SemanticSearchDemo\" target=\"_blank\" rel=\"noopener\">here<\/a> to test drive this, and other powerful semantic search features, in Python for Azure Cosmos DB.<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"14\"><span class=\"hljs-keyword\">from<\/span> azure.cosmos <span class=\"hljs-keyword\">import<\/span> CosmosClient\r\n\r\n<span class=\"hljs-comment\"># Initialize your client<\/span>\r\nclient = CosmosClient(endpoint, key)\r\ncontainer = client.get_database(<span class=\"hljs-string\">\"MyDatabase\"<\/span>).get_container(<span class=\"hljs-string\">\"MyContainer\"<\/span>)\r\n\r\n<span class=\"hljs-comment\"># Perform semantic reranking<\/span>\r\nresults = container.semantic_rerank(\r\n    context=<span class=\"hljs-string\">\"What is the capital of France?\"<\/span>,\r\n    documents=[\r\n        <span class=\"hljs-string\">\"Berlin is the capital of Germany.\"<\/span>,\r\n        <span class=\"hljs-string\">\"Paris is the capital of France.\"<\/span>, \r\n        <span class=\"hljs-string\">\"Madrid is the capital of Spain.\"<\/span>\r\n    ],\r\n    options={\r\n        <span class=\"hljs-string\">\"return_documents\"<\/span>: <span class=\"hljs-literal\">True<\/span>,\r\n        <span class=\"hljs-string\">\"top_k\"<\/span>: <span class=\"hljs-number\">10<\/span>,\r\n        <span class=\"hljs-string\">\"batch_size\"<\/span>: <span class=\"hljs-number\">32<\/span>,\r\n        <span class=\"hljs-string\">\"sort\"<\/span>: <span class=\"hljs-literal\">True<\/span>\r\n    }\r\n)\r\n\r\n<span class=\"hljs-comment\"># Results are intelligently ranked by relevance<\/span>\r\n<span class=\"hljs-built_in\">print<\/span>(results)\r\n<span class=\"hljs-comment\"># Output:<\/span>\r\n<span class=\"hljs-comment\"># {<\/span>\r\n<span class=\"hljs-comment\">#   \"Scores\": [<\/span>\r\n<span class=\"hljs-comment\">#     {<\/span>\r\n<span class=\"hljs-comment\">#       \"index\": 1,<\/span>\r\n<span class=\"hljs-comment\">#       \"document\": \"Paris is the capital of France.\",<\/span>\r\n<span class=\"hljs-comment\">#       \"score\": 0.9921875<\/span>\r\n<span class=\"hljs-comment\">#     },<\/span>\r\n<span class=\"hljs-comment\">#     ...<\/span>\r\n<span class=\"hljs-comment\">#   ]<\/span>\r\n<span class=\"hljs-comment\"># }<\/span>\r\n<\/code><\/pre>\n<p class=\"code-line\" dir=\"auto\" data-line=\"52\">This feature enables you to build more intelligent applications that can understand context and meaning, not just keyword matching. Perfect for RAG (Retrieval-Augmented Generation) patterns in AI applications.<\/p>\n<h3 id=\"read-many-items---optimized-batch-retrieval\" class=\"code-line\" dir=\"auto\" data-line=\"54\">Read Many Items &#8211; Optimized Batch Retrieval<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"56\">The new\u00a0<code>read_items<\/code>\u00a0API revolutionizes how you retrieve multiple documents, offering significant performance improvements and cost savings over individual point reads.<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"58\"><span class=\"hljs-comment\"># Define the items you want to retrieve<\/span>\r\nitem_list = [\r\n    (<span class=\"hljs-string\">\"item1\"<\/span>, <span class=\"hljs-string\">\"partition1\"<\/span>),\r\n    (<span class=\"hljs-string\">\"item2\"<\/span>, <span class=\"hljs-string\">\"partition1\"<\/span>), \r\n    (<span class=\"hljs-string\">\"item3\"<\/span>, <span class=\"hljs-string\">\"partition2\"<\/span>)\r\n]\r\n\r\n<span class=\"hljs-comment\"># Retrieve all items in a single optimized request<\/span>\r\nitems = <span class=\"hljs-built_in\">list<\/span>(container.read_items(\r\n    items=item_list,\r\n    max_concurrency=<span class=\"hljs-number\">100<\/span>\r\n))\r\n\r\n<span class=\"hljs-comment\"># The SDK intelligently groups items by partition and uses<\/span>\r\n<span class=\"hljs-comment\"># optimized backend queries (often IN clauses) to minimize<\/span>\r\n<span class=\"hljs-comment\"># network round trips and RU consumption<\/span>\r\n<\/code><\/pre>\n<p class=\"code-line\" dir=\"auto\" data-line=\"78\"><strong>Performance Benefits<\/strong>:<\/p>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"79\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"79\">Reduces network round trips by up to 90%<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"80\">Lower RU consumption compared to individual reads<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"81\">Intelligent query optimization based on partition distribution<\/li>\n<\/ul>\n<h3 id=\"automatic-write-retries---enhanced-resilience\" class=\"code-line\" dir=\"auto\" data-line=\"83\">Automatic Write Retries &#8211; Enhanced Resilience<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"85\">Say goodbye to manual retry logic for write operations! The SDK now includes built-in retry capabilities for write operations that encounter transient failures.<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"87\"><span class=\"hljs-comment\"># Enable retries at the client level<\/span>\r\nclient = CosmosClient(\r\n    endpoint, \r\n    key,\r\n    connection_policy=ConnectionPolicy(retry_write=<span class=\"hljs-literal\">1<\/span>)\r\n)\r\n\r\n<span class=\"hljs-comment\"># Or enable per-request<\/span>\r\ncontainer.create_item(\r\n    body=my_document,\r\n    retry_write=1 <span class=\"hljs-comment\"># Automatic retry on timeouts\/server errors<\/span>\r\n)\r\n<\/code><\/pre>\n<p class=\"code-line\" dir=\"auto\" data-line=\"102\"><strong>What Gets Retried<\/strong>:<\/p>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"103\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"103\">Timeout errors (408)<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"104\">Server errors (5xx status codes)<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"105\">Transient connectivity issues<\/li>\n<\/ul>\n<p class=\"code-line\" dir=\"auto\" data-line=\"107\"><strong>Smart Retry Logic<\/strong>:<\/p>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"108\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"108\">Single-region accounts: One additional attempt to the same region<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"109\">Multi-region accounts: Cross-regional failover capability<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"110\">Patch operations require explicit opt-in due to potential non-idempotency<\/li>\n<\/ul>\n<h2 id=\"%F0%9F%94%A7-enhanced-developer-experience\" class=\"code-line\" dir=\"auto\" data-line=\"112\">Enhanced Developer Experience<\/h2>\n<h3 id=\"client-level-configuration-options\" class=\"code-line\" dir=\"auto\" data-line=\"114\">Client-Level Configuration Options<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"116\"><strong>Custom User Agent<\/strong>: Identify your applications in telemetry:<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"118\"><span class=\"hljs-comment\"># Set custom user agent suffix for better tracking<\/span>\r\nclient = CosmosClient(\r\n    endpoint, \r\n    key,\r\n    user_agent_suffix=<span class=\"hljs-string\">\"MyApplication\/1.0\"<\/span>\r\n)\r\n<\/code><\/pre>\n<p class=\"code-line\" dir=\"auto\" data-line=\"127\"><strong>Throughput Bucket Headers<\/strong>: Optimize performance monitoring (see <a href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/nosql\/throughput-buckets?tabs=dotnet\" target=\"_blank\" rel=\"noopener\">here<\/a> for more information on throughput buckets):<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"129\"><span class=\"hljs-comment\"># Enable throughput bucket headers for detailed RU tracking<\/span>\r\nclient = CosmosClient(\r\n    endpoint, \r\n    key,\r\n    throughput_bucket=<span class=\"hljs-string\">2<\/span>  <span class=\"hljs-comment\"># Set at client level<\/span>\r\n)\r\n\r\n<span class=\"hljs-comment\"># Or set per request<\/span>\r\ncontainer.create_item(\r\n    body=document,\r\n    throughput_bucket=<span class=\"hljs-string\">2<\/span>\r\n)\r\n<\/code><\/pre>\n<p class=\"code-line\" dir=\"auto\" data-line=\"144\"><strong>Excluded Locations<\/strong>: Fine-tune regional preferences:<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"146\"><span class=\"hljs-comment\"># Exclude specific regions at client level<\/span>\r\nclient = CosmosClient(\r\n    endpoint, \r\n    key,\r\n    excluded_locations=[<span class=\"hljs-string\">\"West US\"<\/span>, <span class=\"hljs-string\">\"East Asia\"<\/span>]\r\n)\r\n\r\n<span class=\"hljs-comment\"># Or exclude regions for specific requests<\/span>\r\ncontainer.read_item(\r\n    item=<span class=\"hljs-string\">\"item-id\"<\/span>,\r\n    partition_key=<span class=\"hljs-string\">\"partition-key\"<\/span>, \r\n    excluded_locations=[<span class=\"hljs-string\">\"Central US\"<\/span>]\r\n)\r\n<\/code><\/pre>\n<h3 id=\"return-properties-with-container-operations\" class=\"code-line\" dir=\"auto\" data-line=\"162\">Return Properties with Container Operations<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"164\">Streamline your workflows with the new\u00a0<code>return_properties<\/code>\u00a0parameter:<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"166\"><span class=\"hljs-comment\"># Get both the container proxy and properties in one call<\/span>\r\ncontainer, properties = database.create_container(\r\n    <span class=\"hljs-built_in\">id<\/span>=<span class=\"hljs-string\">\"MyContainer\"<\/span>,\r\n    partition_key=PartitionKey(path=<span class=\"hljs-string\">\"\/id\"<\/span>),\r\n    return_properties=<span class=\"hljs-literal\">True<\/span>\r\n)\r\n\r\n<span class=\"hljs-comment\"># Now you have immediate access to container metadata<\/span>\r\n<span class=\"hljs-built_in\">print<\/span>(<span class=\"hljs-string\">f\"Container RID: <span class=\"hljs-subst\">{properties['_rid']}<\/span>\"<\/span>)\r\n<span class=\"hljs-built_in\">print<\/span>(<span class=\"hljs-string\">f\"Index Policy: <span class=\"hljs-subst\">{properties['indexingPolicy']}<\/span>\"<\/span>)\r\n<\/code><\/pre>\n<h3 id=\"feed-range-support-in-queries\" class=\"code-line\" dir=\"auto\" data-line=\"179\">Feed Range Support in Queries<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"181\">Unlock advanced parallel change feed processing capabilities:<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"183\"><span class=\"hljs-comment\"># Get feed ranges for parallel processing<\/span>\r\nfeed_ranges = container.get_feed_ranges()\r\n\r\n<span class=\"hljs-comment\"># Query specific feed ranges for optimal parallelism<\/span>\r\n<span class=\"hljs-keyword\">for<\/span> feed_range <span class=\"hljs-keyword\">in<\/span> feed_ranges:\r\n    items = container.query_items(\r\n        query=<span class=\"hljs-string\">\"SELECT * FROM c WHERE c.category = @category\"<\/span>,\r\n        parameters=[{<span class=\"hljs-string\">\"name\"<\/span>: <span class=\"hljs-string\">\"@category\"<\/span>, <span class=\"hljs-string\">\"value\"<\/span>: <span class=\"hljs-string\">\"electronics\"<\/span>}],\r\n        feed_range=feed_range\r\n    )\r\n<\/code><\/pre>\n<p class=\"code-line\" dir=\"auto\" data-line=\"239\"><strong>Enhanced Change Feed<\/strong>: More flexible change feed processing:<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"241\"><span class=\"hljs-comment\"># New change feed mode support for fine-grained control<\/span>\r\nchange_feed_iter = container.query_items_change_feed(\r\n    feed_range=feed_range,\r\n    mode=<span class=\"hljs-string\">\"Incremental\"<\/span>,  <span class=\"hljs-comment\"># New mode support<\/span>\r\n    start_time=datetime.utcnow() - timedelta(hours=<span class=\"hljs-number\">1<\/span>)\r\n)<\/code><\/pre>\n<h3 id=\"vector-embedding-policy-management\" class=\"code-line\" dir=\"auto\" data-line=\"196\">Vector Embedding Policy Management<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"198\">Enhanced support for AI workloads with vector embedding policy updates:<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"200\"><span class=\"hljs-comment\"># Update indexing policy for containers with vector embeddings<\/span>\r\nindexing_policy = {\r\n    <span class=\"hljs-string\">\"indexingMode\"<\/span>: <span class=\"hljs-string\">\"consistent\"<\/span>,\r\n    <span class=\"hljs-string\">\"vectorIndexes\"<\/span>: [\r\n        {\r\n            <span class=\"hljs-string\">\"path\"<\/span>: <span class=\"hljs-string\">\"\/vector\"<\/span>,\r\n            <span class=\"hljs-string\">\"type\"<\/span>: <span class=\"hljs-string\">\"quantizedFlat\"<\/span>\r\n        }\r\n    ]\r\n}\r\n\r\n<span class=\"hljs-comment\"># Now you can replace indexing policies even when vector embeddings are present<\/span>\r\ncontainer.replace_container(\r\n    container=container_properties,\r\n    indexing_policy=indexing_policy\r\n)\r\n<\/code><\/pre>\n<h3 id=\"advanced-query-capabilities\" class=\"code-line\" dir=\"auto\" data-line=\"219\">Advanced Query Capabilities<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"221\"><strong>Weighted RRF for Hybrid Search<\/strong>: Enhance your search relevance with Reciprocal Rank Fusion:<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"223\"><span class=\"hljs-comment\"># Use weighted RRF in hybrid search queries<\/span>\r\nquery = <span class=\"hljs-string\">\"\"\"\r\nSELECT c.id, c.title, c.content \r\nFROM c \r\nWHERE CONTAINS(c.title, \"machine learning\") \r\nORDER BY RRF(VectorDistance(c.embedding, @vector), \r\n             FullTextScore(c.content, \"artificial intelligence\"), \r\n             [0.7, 0.3])\r\n\"\"\"<\/span>\r\n\r\nitems = container.query_items(query=query, parameters=[\r\n    {<span class=\"hljs-string\">\"name\"<\/span>: <span class=\"hljs-string\">\"@vector\"<\/span>, <span class=\"hljs-string\">\"value\"<\/span>: search_vector}\r\n])<\/code><\/pre>\n<h3 id=\"computed-properties-now-ga\" class=\"code-line\" dir=\"auto\" data-line=\"250\">Computed Properties (Now GA)<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"252\">Computed Properties have graduated from preview to general availability:<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"254\"><span class=\"hljs-comment\"># Define computed properties for efficient querying<\/span>\r\ncomputed_properties = [\r\n    {\r\n        <span class=\"hljs-string\">\"name\"<\/span>: <span class=\"hljs-string\">\"lowerCaseName\"<\/span>, \r\n        <span class=\"hljs-string\">\"query\"<\/span>: <span class=\"hljs-string\">\"SELECT VALUE LOWER(c.name) FROM c\"<\/span>\r\n    }\r\n]\r\n\r\n<span class=\"hljs-comment\"># Replace container with computed properties<\/span>\r\ncontainer.replace_container(\r\n    container=container_properties,\r\n    computed_properties=computed_properties\r\n)\r\n\r\n<span class=\"hljs-comment\"># Query using computed properties for better performance<\/span>\r\nitems = container.query_items(\r\n    query=<span class=\"hljs-string\">\"SELECT * FROM c WHERE c.lowerCaseName = 'john doe'\"<\/span>\r\n)\r\n<\/code><\/pre>\n<h2 dir=\"auto\" data-line=\"275\"><\/h2>\n<h2 id=\"%F0%9F%9B%A1%EF%B8%8F-reliability-and-performance-improvements\" class=\"code-line\" dir=\"auto\" data-line=\"275\">Reliability and Performance Improvements<\/h2>\n<h3 id=\"advanced-session-management\" class=\"code-line\" dir=\"auto\" data-line=\"277\">Advanced Session Management<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"279\">The SDK now includes sophisticated session token management:<\/p>\n<ul>\n<li>Automatically optimizes session tokens<\/li>\n<li>Sends only relevant partition-local tokens for reads<\/li>\n<li>Eliminates unnecessary session tokens for single-region writes<\/li>\n<li>Improves performance and reduces request size<\/li>\n<\/ul>\n<h3 id=\"circuit-breaker-support\" class=\"code-line\" dir=\"auto\" data-line=\"288\">Circuit Breaker Support<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"290\">Enable partition-level circuit breakers for enhanced fault tolerance:<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"292\"><span class=\"hljs-keyword\">import<\/span> os\r\n\r\n<span class=\"hljs-comment\"># Enable circuit breaker via environment variable<\/span>\r\nos.environ[<span class=\"hljs-string\">'AZURE_COSMOS_ENABLE_CIRCUIT_BREAKER'<\/span>] = <span class=\"hljs-string\">'true'<\/span>\r\n\r\n<span class=\"hljs-comment\"># The SDK will automatically isolate failing partitions<\/span>\r\n<span class=\"hljs-comment\"># while keeping healthy partitions available<\/span>\r\n<\/code><\/pre>\n<h3 id=\"enhanced-error-handling\" class=\"code-line\" dir=\"auto\" data-line=\"302\">Enhanced Error Handling<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"304\">More resilient retry logic with cross-regional capabilities.<\/p>\n<h2 id=\"%F0%9F%94%8D-monitoring-and-diagnostics\" class=\"code-line\" dir=\"auto\" data-line=\"313\">Monitoring and Diagnostics<\/h2>\n<h3 id=\"enhanced-logging-and-diagnostics\" class=\"code-line\" dir=\"auto\" data-line=\"315\">Enhanced Logging and Diagnostics<\/h3>\n<p>Automatic failover improvements:<\/p>\n<ul>\n<li>Better handling of bounded staleness consistency<\/li>\n<li>Cross-region retries when no preferred locations are set<\/li>\n<li>Improved database account call resilience<\/li>\n<\/ul>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"317\"><span class=\"hljs-keyword\">import<\/span> logging\r\n<span class=\"hljs-keyword\">from<\/span> azure.cosmos <span class=\"hljs-keyword\">import<\/span> CosmosHttpLoggingPolicy<\/code> <span class=\"hljs-comment\"># Set up enhanced logging<\/span> logging.basicConfig(level=logging.INFO) client = CosmosClient( endpoint, key, logging_policy=CosmosHttpLoggingPolicy(logger=logging.getLogger()) )<\/pre>\n<h2 id=\"%F0%9F%8E%AF-the-openai-connection\" class=\"code-line\" dir=\"auto\" data-line=\"335\">The OpenAI Connection<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"337\">Many of these features were developed in collaboration with\u00a0<strong>OpenAI<\/strong>, who use Cosmos DB extensively for ChatGPT&#8217;s data storage needs. This partnership ensures our SDK can handle:<\/p>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"339\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"339\"><strong>Massive Scale<\/strong>: Billions of operations per day<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"340\"><strong>Low Latency<\/strong>: Sub-10ms response times for AI workloads<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"341\"><strong>High Availability<\/strong>: 99.999% uptime requirements<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"342\"><strong>Global Distribution<\/strong>: Seamless worldwide data replication<\/li>\n<\/ul>\n<p class=\"code-line\" dir=\"auto\" data-line=\"344\">When you use the <a href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/nosql\/sdk-python\" target=\"_blank\" rel=\"noopener\">Python SDK for Azure Cosmos DB<\/a>, you&#8217;re leveraging the same technology that powers some of the world&#8217;s most advanced AI applications.<\/p>\n<h2 id=\"%F0%9F%93%8A-real-world-impact\" class=\"code-line\" dir=\"auto\" data-line=\"346\">Real-World Impact<\/h2>\n<h3 id=\"performance-benchmarks\" class=\"code-line\" dir=\"auto\" data-line=\"348\">Performance Benchmarks<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"350\">Based on testing with synthetic workloads:<\/p>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"352\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"352\"><strong>Read Many Items<\/strong>: Up to 85% reduction in latency for batch retrieval scenarios<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"353\"><strong>Write Retries<\/strong>: 99.5% reduction in transient failure impact<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"354\"><strong>Session Optimization<\/strong>: 60% reduction in session token overhead<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"355\"><strong>Circuit Breaker<\/strong>: 90% faster recovery from partition-level failures<\/li>\n<\/ul>\n<h3 id=\"cost-optimization\" class=\"code-line\" dir=\"auto\" data-line=\"357\">Cost Optimization<\/h3>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"359\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"359\"><strong>Reduced RU Consumption<\/strong>: Batch operations can reduce costs by up to 40%<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"360\"><strong>Fewer Network Calls<\/strong>: Significant bandwidth savings in high-throughput scenarios<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"361\"><strong>Optimized Retries<\/strong>: Intelligent retry logic prevents unnecessary RU charges<\/li>\n<\/ul>\n<h2 id=\"%F0%9F%9A%A8-breaking-changes-important\" class=\"code-line\" dir=\"auto\" data-line=\"363\">Breaking Changes (Important!)<\/h2>\n<p>If you have been using the beta versions of Python SDK (since the last stable version 4.9.0) there is one breaking change:<\/p>\n<h3 id=\"changed-retry_write-parameter-type\" class=\"code-line\" dir=\"auto\" data-line=\"365\">Changed\u00a0<code>retry_write<\/code>\u00a0Parameter Type<\/h3>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"367\"><span class=\"hljs-comment\"># Before (4.13.x and earlier)<\/span>\r\nretry_write = <span class=\"hljs-literal\">True<\/span>  <span class=\"hljs-comment\"># boolean<\/span>\r\n\r\n<span class=\"hljs-comment\"># After (4.14.0)<\/span>\r\nretry_write = <span class=\"hljs-number\">3<\/span>  <span class=\"hljs-comment\"># integer (number of retries)<\/span>\r\n<\/code><\/pre>\n<p class=\"code-line\" dir=\"auto\" data-line=\"375\">This change aligns with other retry configuration options and provides more granular control.<\/p>\n<h2 id=\"%F0%9F%9B%A3%EF%B8%8F-migration-guide\" class=\"code-line\" dir=\"auto\" data-line=\"377\">Migration Guide<\/h2>\n<h3 id=\"upgrading-from-490-to-4140\" class=\"code-line\" dir=\"auto\" data-line=\"379\">Upgrading from any beta higher than 4.9.0 to 4.14.0<\/h3>\n<ol class=\"code-line\" dir=\"auto\" data-line=\"381\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"381\">\n<p class=\"code-line\" dir=\"auto\" data-line=\"381\"><strong>Update your dependencies<\/strong>:<\/p>\n<pre><code class=\"code-line language-bash\" dir=\"auto\" data-line=\"382\">pip install azure-cosmos==4.14.0\r\n<\/code><\/pre>\n<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"386\">\n<p class=\"code-line\" dir=\"auto\" data-line=\"386\"><strong>Update retry_write usage<\/strong>\u00a0(if applicable):<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"387\"><span class=\"hljs-comment\"># Old way<\/span>\r\nclient = CosmosClient(endpoint, key, retry_write=<span class=\"hljs-literal\">True<\/span>)\r\n\r\n<span class=\"hljs-comment\"># New way  <\/span>\r\nclient = CosmosClient(endpoint, key, retry_write=<span class=\"hljs-number\">3<\/span>)\r\n<\/code><\/pre>\n<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"395\">\n<p class=\"code-line\" dir=\"auto\" data-line=\"395\"><strong>Leverage new features<\/strong>\u00a0(optional but recommended):<\/p>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"381\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"395\">\n<p class=\"code-line\" dir=\"auto\" data-line=\"395\">Take advantage of read_items for batch operations<\/p>\n<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"395\">\n<p class=\"code-line\" dir=\"auto\" data-line=\"395\">Enable automatic write retries for resilience<\/p>\n<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"395\">\n<p class=\"code-line\" dir=\"auto\" data-line=\"395\">Use return_properties to reduce API calls<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h2 id=\"%F0%9F%94%AC-whats-next\" class=\"code-line\" dir=\"auto\" data-line=\"402\">What&#8217;s Next?<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"404\">This release establishes the foundation for even more exciting AI-focused features coming in future versions:<\/p>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"406\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"406\">Enhanced vector search capabilities<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"407\">Advanced semantic search integration<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"408\">Expanded AI inference service integrations<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"409\">Performance optimizations for RAG patterns<\/li>\n<\/ul>\n<h2 id=\"%F0%9F%93%9A-additional-resources\" class=\"code-line\" dir=\"auto\" data-line=\"411\">Additional Resources<\/h2>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"413\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"413\"><strong><a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-python\/blob\/main\/sdk\/cosmos\/azure-cosmos\/CHANGELOG.md\" data-href=\"https:\/\/github.com\/Azure\/azure-sdk-for-python\/blob\/main\/sdk\/cosmos\/azure-cosmos\/CHANGELOG.md\">Full Changelog<\/a><\/strong>\u00a0&#8211; Complete list of changes including bug fixes since 4.9.0<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"414\"><strong><a href=\"https:\/\/docs.microsoft.com\/python\/api\/azure-cosmos\/\" data-href=\"https:\/\/docs.microsoft.com\/python\/api\/azure-cosmos\/\">SDK Documentation<\/a><\/strong>\u00a0&#8211; Comprehensive API reference<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"415\"><strong><a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-python\/tree\/main\/sdk\/cosmos\/azure-cosmos\/samples\" data-href=\"https:\/\/github.com\/Azure\/azure-sdk-for-python\/tree\/main\/sdk\/cosmos\/azure-cosmos\/samples\">Sample Code<\/a><\/strong>\u00a0&#8211; Working examples for all new features<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"416\"><strong><a href=\"https:\/\/docs.microsoft.com\/azure\/cosmos-db\/sql\/migrate-python-sdk-v4\" data-href=\"https:\/\/docs.microsoft.com\/azure\/cosmos-db\/sql\/migrate-python-sdk-v4\">Migration Guide<\/a><\/strong>\u00a0&#8211; Step-by-step upgrade instructions<\/li>\n<\/ul>\n<h2 id=\"%F0%9F%A4%9D-get-involved\" class=\"code-line\" dir=\"auto\" data-line=\"418\">Get Involved<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"420\">Have feedback or questions? We&#8217;d love to hear from you!<\/p>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"422\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"422\"><strong>GitHub Issues<\/strong>:\u00a0<a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-python\/issues\" data-href=\"https:\/\/github.com\/Azure\/azure-sdk-for-python\/issues\">Report bugs or request features<\/a><\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"423\"><strong>Stack Overflow<\/strong>: Tag your questions with\u00a0<code>azure-cosmosdb<\/code>\u00a0and\u00a0<code>python<\/code><\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"424\"><strong>Documentation<\/strong>:\u00a0<a href=\"https:\/\/github.com\/MicrosoftDocs\/azure-docs\" data-href=\"https:\/\/github.com\/MicrosoftDocs\/azure-docs\">Contribute to our docs<\/a><\/li>\n<\/ul>\n<hr class=\"code-line\" dir=\"auto\" data-line=\"426\" \/>\n<p class=\"code-line\" dir=\"auto\" data-line=\"428\"><strong>Ready to upgrade?<\/strong>\u00a0Install Azure Cosmos DB Python SDK v4.14.0 today and experience the power of AI-enhanced database operations!<\/p>\n<pre><code class=\"code-line language-bash\" dir=\"auto\" data-line=\"430\">pip install --upgrade azure-cosmos==4.14.0\r\n<\/code><\/pre>\n<p class=\"code-line\" dir=\"auto\" data-line=\"434\"><em>The future of AI-powered applications starts with the right data foundation. With the latest Cosmos DB Python SDK, you have the tools to build intelligent, scalable, and resilient applications that can handle anything the world throws at them.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;re thrilled to announce the stable release of Azure Cosmos DB Python SDK version 4.14.0! This release brings together months of innovation and collaboration, featuring ground-breaking capabilities that have been battle-tested in production environments. Many of these features were developed in close partnership with OpenAI, who rely heavily on Cosmos DB to store chat data [&hellip;]<\/p>\n","protected":false},"author":9387,"featured_media":10944,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[14,1217],"tags":[],"class_list":["post-10925","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-core-sql-api","category-python-sdk"],"acf":[],"blog_post_summary":"<p>We&#8217;re thrilled to announce the stable release of Azure Cosmos DB Python SDK version 4.14.0! This release brings together months of innovation and collaboration, featuring ground-breaking capabilities that have been battle-tested in production environments. Many of these features were developed in close partnership with OpenAI, who rely heavily on Cosmos DB to store chat data [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/10925","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/users\/9387"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/comments?post=10925"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/10925\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media\/10944"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media?parent=10925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/categories?post=10925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/tags?post=10925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}