Note
The Dedalus API PostgreSQL Extension is currently experimental and we're excited for you to experiment with it!
This extension has not yet been exhaustively tested in production environments and may be missing some features you'd expect in a stable release. As we continue development, there may be breaking changes that require updates to your code.
We'd love your feedback! Please share any suggestions, bug reports, feature requests, or general thoughts by filing an issue.
The Dedalus API PostgreSQL Extension provides convenient access to the Dedalus REST API from PostgreSQL.
It is generated with Stainless.
The REST API documentation can be found on docs.dedaluslabs.ai.
Clone the repository:
git clone git@github.com:stainless-sdks/dedalus-sdk-sql.git
cd dedalus-sdk-sqlInstall the extension:
make installLoad it into the relevant database:
CREATE EXTENSION IF NOT EXISTS plpython3u; -- Dependency
CREATE EXTENSION dedalus_sdk;And install the Python SDK dependency:
# install from PyPI
pip install dedalus_labsSee ./scripts/test how to use a Python virtual environment if you prefer that instead.
Use the troubleshooting section if you encounter issues during or after installation.
This extension requires:
- PostgreSQL 14 or higher
- PL/Python
- Python 3.9 or higher
- The dedalus_labs Python package
SELECT *
FROM dedalus_sdk_models.retrieve(model_id := 'model_id');Configure the client by setting configuration parameters at the database level:
ALTER DATABASE my_database SET dedalus_sdk.api_key = 'My API Key';Note
ALTER DATABASE persistently alters the database, but doesn't take effect until the next session. To
ephemerally modify the current session, use SET dedalus_sdk.api_key TO 'My API Key';.
See this table for the available configuration parameters:
| Parameter | Required | Default value |
|---|---|---|
dedalus_sdk.api_key |
false | - |
dedalus_sdk.x_api_key |
false | - |
dedalus_sdk.as_url |
false | 'https://as.dedaluslabs.ai' |
dedalus_sdk.org_id |
false | - |
dedalus_sdk.provider |
false | - |
dedalus_sdk.provider_key |
false | - |
dedalus_sdk.provider_model |
false | - |
dedalus_sdk.base_url |
false | 'https://api.dedaluslabs.ai' |
dedalus_sdk.environment |
false | 'production' |
dedalus_sdk.environment supports the following values:
productiondevelopment
To send a request to the Dedalus API, call the relevant SQL function with values corresponding to the parameter types and SELECT the columns you need from the returned rows.
To construct composite type parameters, use the parameter type's provided make_* function. For example, dedalus_sdk_chat_completions.chat_completion_audio_param may be constructed like so:
dedalus_sdk_chat_completions.make_chat_completion_audio_param(
format := 'mp3',
voice := $$
"alloy"
$$::JSONB
)If you encounter an error such as:
Operation not permitted
Then run with sudo. If necessary, ensure your terminal has full disk access.
If you encounter an error such as:
make: pg_config: Command not found
Then ensure you have pg_config installed and in your PATH. If necessary, tell make where to find it:
PG_CONFIG=/path/to/pg_config make installTo install the extension in a custom prefix on PostgreSQL 18 or later, pass the prefix argument:
make install prefix=/usr/local/extrasYou must also ensure that the prefix is included in the following postgresql.conf parameters:
extension_control_path = '/usr/local/extras/postgresql/share:$system'
dynamic_library_path = '/usr/local/extras/postgresql/lib:$libdir'If you encounter an error such as:
ERROR: could not load library
Then ensure your Python installation is linked to the directory where PostgreSQL was looking for it. You can print out the directory of your Python installation with this command:
python3 -c "import sys; print(sys.prefix)"This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:
- Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
- Changes that we do not expect to impact the vast majority of users in practice.
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
We are keen for your feedback; please open an issue with questions, bugs, or suggestions.