ConnectorTypeAZUREAI
class connector_types.connector_type_azureai.ConnectorTypeAZUREAI
Call an Azure AI API.
See https://learn.microsoft.com/en-us/python/api/?view=azure-python&term=azure-ai
Input Schema
-
schema_version
Type:
string
-
authentication
Type:
anyOf
Options: -
endpoint
Supported Cognitive Services endpoints (protocol and hostname), for example: https://westus2.api.cognitive.microsoft.com.
Type:
string
-
api_version
The API version to use for the request.
Type:
anyOf
Options: -
mode
Type:
anyOf
Options:
Output Schema
Constants
SUPPORTED_CLIENTS = ['documentanalysis', 'documentmodeladministration']Example
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
analyze_result = this.connect(
connector_type='AZUREAI',
authentication={
'authentication_method': 'azure_ad',
client_id='...',
client_secret='...',
tenant_id='...',
},
endpoint='...',
api_version='...',
mode={
'mode_name': 'call_client_method',
'client': 'documentanalysis',
'method': 'begin_analyze_document',
'kwargs': {
'model_id': '...',
'document': 'cloudomation:file-name.pdf',
'pages': '1-3,5-6',
'locale': 'de',
},
},
).get('output_value')['result']
this.log(analyze_result=analyze_result)
return this.success('all done')
More
Key authentication
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
analyze_result = this.connect(
connector_type='AZUREAI',
authentication={
'authentication_method': 'azure_api_key',
'api_key': '...',
},
...
).get('output_value')['result']
this.log(analyze_result=analyze_result)
return this.success('all done')
Pass document bytes directly
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
document_bytes = b'...'
analyze_result = this.connect(
connector_type='AZUREAI',
authentication={
'authentication_method': 'azure_ad',
client_id='...',
client_secret='...',
tenant_id='...',
},
endpoint='...',
api_version='...',
mode={
'mode_name': 'call_client_method',
'client': 'documentanalysis',
'method': 'begin_analyze_document',
'kwargs': {
'model_id': '...',
'document': document_bytes,
'pages': '1-3,5-6',
'locale': 'de',
},
},
).get('output_value')['result']
this.log(analyze_result=analyze_result)
return this.success('all done')