AI service

OpenAI

The OpenAI integration connects your project to the OpenAI API — with a shared, Dreambase-managed key or a dedicated key you provide — exposes the connection details as outputs, and offers chat completions, embeddings, and model listing via function calls, plus health checks and metrics.

OpenAI is one of the AI service integrations. It handles its own webhook route:

POST/openai/webhook
Connect to the OpenAI API (shared or dedicated)

What it does

On DEPLOYMENT_CREATED the service resolves the key (shared or dedicated), verifies it against the OpenAI /models endpoint, and publishes the connection details — apiKey, models, and apiUrl — back to Dreambase as outputs for other services to consume. The deployment connects to the provider API; there is no infrastructure to provision.

Instance type

  • shared (default) — use the Dreambase-managed OpenAI key (OPENAI_SHARED_API_KEY). Ideal for MVPs and development, with no setup required.
  • dedicated — bring your own OpenAI API key, with an optional organization ID.

Choosing models

The models input is a comma-separated list of the model IDs you want to work with (e.g. gpt-4o, gpt-4o-mini). The first one is used as the default when a function call doesn't name a model. Configured models that the key can't see are logged as a warning at configure time, but don't fail the connection.

Inputs

InputApplies toDescription
serverTypeallEither shared (default) or dedicated.
apiKeydedicatedYour OpenAI API key. Accepts a {{env.KEY}} reference.
organizationIddedicatedOptional. Sent as the OpenAI-Organization header.
baseUrlallOptional. Target Azure OpenAI or an OpenAI-compatible gateway (default https://api.openai.com/v1).
modelsallComma-separated model IDs to work with. The first is the default.

Outputs

  • apiKey — the resolved OpenAI API key.
  • models — the comma-separated list of configured model IDs.
  • apiUrl — the base URL used for API requests.
  • organizationId — the OpenAI organization ID, when provided.

Functions

Callable via a FUNCTION_CALL event:

  • listModels — list the model IDs available to the key.
  • chatCompletion — generate a chat completion. Provide either a full messages array or a simple prompt (with an optional system message), plus optional model, maxTokens, and temperature. Returns the message content, model, and usage.
  • createEmbedding — embed a string or array of strings with a given model. Returns the embeddings array.

Metrics

On METRIC_UPDATE the service reports available_models (the number of models the key can access) and configured_models (the number selected for this service).

Events it handles

  • WEBHOOK_CHALLENGE — verify the webhook endpoint.
  • HEALTH_CHECK — probe the OpenAI /models endpoint with the configured key.
  • METRIC_UPDATE — report available and configured model counts.
  • DEPLOYMENT_CREATED — verify the key and publish the connection details as outputs.
  • DEPLOYMENT_DELETED — stop tracking the connection (nothing external is torn down).
  • FUNCTION_CALL — run a named function.