1. Provider¶
An AI Provider in Select AI refers to the service provider of the LLM, transformer or both for processing and generating responses to natural language prompts. These providers offer models that can interpret and convert natural language for the use cases highlighted under the LLM concept.
See Select your AI Provider for the supported providers.
A provider object describes the AI service that a Select AI profile, vector index, or agent tool should call. The provider object is separate from the credential object: the provider selects the service, model, endpoint, region, and provider-specific options, while the credential stores authentication details.
Most applications should instantiate one of the concrete provider classes
instead of using Provider directly. Use the base Provider class when
you need to call a compatible provider endpoint that does not have a dedicated
class in this library.
Provider class |
Provider name |
Default endpoint behavior |
|---|---|---|
|
|
Uses |
|
|
Builds |
|
|
Builds |
|
|
Uses |
|
|
Uses |
|
|
Uses |
|
|
Uses OCI region and OCI Gen AI attributes. |
|
|
Uses |
1.1. Examples¶
OCI Gen AI provider:
provider = select_ai.OCIGenAIProvider(
region="us-chicago-1",
oci_apiformat="GENERIC",
model="cohere.command-r-plus",
)
OpenAI provider:
provider = select_ai.OpenAIProvider(
model="gpt-4.1",
)
Azure OpenAI provider:
provider = select_ai.AzureProvider(
azure_resource_name="my-azure-openai-resource",
azure_deployment_name="gpt-4o-deployment",
azure_embedding_deployment_name="text-embedding-deployment",
)
AWS Bedrock provider:
provider = select_ai.AWSProvider(
region="us-east-1",
aws_apiformat="ANTHROPIC",
model="anthropic.claude-3-5-sonnet-20240620-v1:0",
)
Custom provider endpoint:
select_ai.create_credential(
credential={
"credential_name": "xai_credential",
"username": "xai",
"password": "<xai_api_key>",
},
replace=True,
)
xai_profile = select_ai.Profile(
profile_name="xai",
attributes=select_ai.ProfileAttributes(
provider=select_ai.Provider(
provider_endpoint="https://api.x.ai",
model="grok-4-1-fast-reasoning",
),
credential_name="xai_credential",
object_list=[
{"owner": "SH", "name": "CUSTOMERS"},
{"owner": "SH", "name": "SALES"},
{"owner": "SH", "name": "PRODUCTS"},
{"owner": "SH", "name": "COUNTRIES"},
],
),
replace=True,
)
sql = xai_profile.show_sql(
prompt="How many customers do I have?",
)
1.2. Provider¶
- class select_ai.Provider(embedding_model: str | None = None, model: str | None = None, provider_name: str | None = None, provider_endpoint: str | None = None, region: str | None = None)¶
Base class for AI Provider
To create an object of Provider class, use any one of the concrete AI provider implementations
- Parameters:
embedding_model (str) – The embedding model, also known as a transformer. Depending on the AI provider, the supported embedding models vary
model (str) – The name of the LLM being used to generate responses
provider_name (str) – The name of the provider being used
provider_endpoint (str) – Endpoint URL of the AI provider being used
region (str) – The cloud region of the Gen AI cluster
1.3. AnthropicProvider¶
- class select_ai.AnthropicProvider(embedding_model: str | None = None, model: str | None = None, provider_name: str = 'anthropic', provider_endpoint: str | None = None, region: str | None = None)¶
Anthropic specific attributes
1.4. AzureProvider¶
- class select_ai.AzureProvider(embedding_model: str | None = None, model: str | None = None, provider_name: str = 'azure', provider_endpoint: str | None = None, region: str | None = None, azure_deployment_name: str | None = None, azure_embedding_deployment_name: str | None = None, azure_resource_name: str | None = None)¶
Azure specific attributes
- Parameters:
azure_deployment_name (str) – Name of the Azure OpenAI Service deployed model.
azure_embedding_deployment_name (str) – Name of the Azure OpenAI deployed embedding model.
azure_resource_name (str) – Name of the Azure OpenAI Service resource
1.5. AWSProvider¶
- class select_ai.AWSProvider(embedding_model: str | None = None, model: str | None = None, provider_name: str = 'aws', provider_endpoint: str | None = None, region: str | None = None, aws_apiformat: str | None = None)¶
AWS specific attributes
1.6. CohereProvider¶
- class select_ai.CohereProvider(embedding_model: str | None = None, model: str | None = None, provider_name: str = 'cohere', provider_endpoint: str | None = None, region: str | None = None)¶
Cohere AI specific attributes
1.7. OpenAIProvider¶
- class select_ai.OpenAIProvider(embedding_model: str | None = None, model: str | None = None, provider_name: str = 'openai', provider_endpoint: str | None = 'api.openai.com', region: str | None = None)¶
OpenAI specific attributes
1.8. OCIGenAIProvider¶
- class select_ai.OCIGenAIProvider(embedding_model: str | None = None, model: str | None = None, provider_name: str = 'oci', provider_endpoint: str | None = None, region: str | None = None, oci_apiformat: str | None = None, oci_compartment_id: str | None = None, oci_endpoint_id: str | None = None, oci_runtimetype: str | None = None)¶
OCI Gen AI specific attributes
- Parameters:
oci_apiformat (str) – Specifies the format in which the API expects data to be sent and received. Supported values are ‘COHERE’ and ‘GENERIC’
oci_compartment_id (str) – Specifies the OCID of the compartment you are permitted to access when calling the OCI Generative AI service
oci_endpoint_id (str) – This attributes indicates the endpoint OCID of the Oracle dedicated AI hosting cluster
oci_runtimetype (str) – This attribute indicates the runtime type of the provided model. The supported values are ‘COHERE’ and ‘LLAMA’
1.9. GoogleProvider¶
- class select_ai.GoogleProvider(embedding_model: str | None = None, model: str | None = None, provider_name: str = 'google', provider_endpoint: str | None = None, region: str | None = None)¶
Google AI specific attributes
1.10. HuggingFaceProvider¶
- class select_ai.HuggingFaceProvider(embedding_model: str | None = None, model: str | None = None, provider_name: str = 'huggingface', provider_endpoint: str | None = None, region: str | None = None)¶
HuggingFace specific attributes
1.11. Enable AI service provider¶
1.11.1. Enable using Sync API¶
This method adds ACL allowing database users to invoke AI provider’s HTTP endpoint. For non-HTTP or port-specific network access, use the network ACL helpers described in Privileges.
import os
import select_ai
admin_user = os.getenv("SELECT_AI_ADMIN_USER")
password = os.getenv("SELECT_AI_ADMIN_PASSWORD")
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
select_ai_user = os.getenv("SELECT_AI_USER")
select_ai.connect(user=admin_user, password=password, dsn=dsn)
select_ai.grant_http_access(
users=select_ai_user, provider_endpoint="api.OPENAI.com"
)
print("Enabled AI provider for user: ", select_ai_user)
output:
Enabled AI provider for user: <select_ai_db_user>
1.11.2. Enable using Async API¶
import asyncio
import os
import select_ai
admin_user = os.getenv("SELECT_AI_ADMIN_USER")
password = os.getenv("SELECT_AI_ADMIN_PASSWORD")
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
select_ai_user = os.getenv("SELECT_AI_USER")
async def main():
await select_ai.async_connect(user=admin_user, password=password, dsn=dsn)
await select_ai.async_grant_http_access(
users=select_ai_user, provider_endpoint="*.openai.azure.com"
)
print("Enabled AI provider for user: ", select_ai_user)
asyncio.run(main())
output:
Enabled AI provider for user: <select_ai_db_user>
1.12. Disable AI service provider¶
This method removes the ACL entry that allows database users to invoke an AI provider’s HTTP endpoint.
1.12.1. Disable using Sync API¶
import os
import select_ai
admin_user = os.getenv("SELECT_AI_ADMIN_USER")
password = os.getenv("SELECT_AI_ADMIN_PASSWORD")
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
select_ai_user = os.getenv("SELECT_AI_USER")
select_ai.connect(user=admin_user, password=password, dsn=dsn)
select_ai.revoke_http_access(
users=select_ai_user, provider_endpoint="*.openai.azure.com"
)
print("Disabled AI provider for user: ", select_ai_user)
output:
Disabled AI provider for user: <select_ai_db_user>
1.12.2. Disable using Async API¶
import asyncio
import os
import select_ai
admin_user = os.getenv("SELECT_AI_ADMIN_USER")
password = os.getenv("SELECT_AI_ADMIN_PASSWORD")
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
select_ai_user = os.getenv("SELECT_AI_USER")
async def main():
await select_ai.async_connect(user=admin_user, password=password, dsn=dsn)
await select_ai.async_revoke_http_access(
users=select_ai_user, provider_endpoint="*.openai.azure.com"
)
print("Disabled AI provider for user: ", select_ai_user)
asyncio.run(main())
output:
Disabled AI provider for user: <select_ai_db_user>