Overview

Hosts establish connectivity to external services. They’re used for HTTP and GraphQL APIs, database connections, and externally hosted AI models. The hosts object in the project manifest allows you to define these hosts, for secure access from within a function.

Each host requires a unique name, specified as a key containing only alphanumeric characters and hyphens.

Each host has a type property, which controls how it’s used and which additional properties are available. If not provided, the default type is http. The following table lists the available host types:

TypePurposeFunctions Namespaces
httpConnect to an HTTP or HTTPS web serverhttp, graphql, models
postgresqlConnect to a PostgreSQL databasepostgresql

We’ll update this table as we add more host types.

Caution

Don’t include secrets directly in the manifest!

If your host requires authentication, you can include placeholders in host properties which resolve to their respective secrets at runtime. Set the actual secrets via the Hypermode Console, where they’re securely stored until needed.

HTTP Host

This host type supports the HTTP and HTTPS protocols to communicate with external hosts. You can use the HTTP APIs in the Functions SDK to interact with the host.

This host type is also used for GraphQL APIs and to invoke externally hosted AI models.

Example:

hypermode.json
{
  "hosts": {
    "openai": {
      "baseUrl": "https://api.openai.com/",
      "headers": {
        "Authorization": "Bearer {{API_KEY}}"
      }
    }
  }
}
type
string

Always set to "http" for this host type. This is the default if not specified.

baseUrl
string
required

Base URL for connections to the host.

  • Must end with a trailing slash.
  • May contain path segments if necessary.

Example: "https://api.example.com/v1/"

endpoint
string
required

Full URL endpoint for connections to the host.

Example: "https://models.example.com/v1/classifier"

You must include either a baseUrl or an endpoint, but not both.

  • Use baseUrl for connections to a host with a common base URL.
  • Use endpoint for connections to a specific URL.

Typically, you’ll use the baseUrl field. However, some APIs, such as graphql.execute, require the full URL in the endpoint field.

headers
object

If provided, requests to the host include these headers. Each key-value pair is a header name and value.

Values may include variables using the {{VARIABLE}} template syntax, which resolve at runtime to secrets provided for each host, via the Hypermode Console.

queryParameters
object

If provided, requests to the host include these query parameters, appended to the URL. Each key-value pair is a parameter name and value.

Values may include variables using the {{VARIABLE}} template syntax, which resolve at runtime to secrets provided for each host, via the Hypermode Console.

PostgreSQL Host

This host type supports connecting to PostgreSQL databases. You can use the PostgreSQL APIs in the Functions SDK to interact with the database.

Example:

hypermode.json
{
  "hosts": {
    "my-database": {
      "type": "postgresql",
      "connString": "postgresql://{{PG_USER}}:{{PG_PASSWORD}}@db.example.com:5432/data?sslmode=require"
    }
  }
}
type
string
required

Always set to "postgresql" for this host type.

connString
string
required

The connection string for the PostgreSQL database.

Values may include variables using the {{VARIABLE}} template syntax, which resolve at runtime to secrets provided for each host, via the Hypermode Console.

The connection string in the preceding example includes:

  • A username and password provided by secrets named PG_USER & PG_PASSWORD
  • A host named db.example.com on port 5432
  • A database named data
  • SSL mode set to require - which is highly recommended for secure connections

Refer to the PostgreSQL documentation for more details on connection strings.

Managed PostgreSQL providers often provide a pre-made connection string for you to copy. Check your provider’s documentation for details.

For example, if using Neon, refer to the Neon documentation.