Skip to main content

What are API Keys?

API keys are project-scoped credentials that authenticate requests to Daft Cloud inference endpoints and track usage.

What API Keys Do

  • Authenticate requests to Daft Cloud model inference endpoints
  • Track usage and costs per key
  • Enable access control with separate keys for different applications

Creating an API Key

  1. Navigate to API Keys in your project sidebar
  2. Click Create API key
  3. Enter a descriptive name (e.g., development, production-app)
  4. Click Create
  5. Copy the key immediately - it will only be shown once

Key Format

API keys follow this format: sk-... (the full key is only shown once upon creation). After creation, you’ll only see a hint like sk-...Ac4A for identification. API keys are not stored and cannot be retrieved—if you lose your key, you’ll need to create a new one.

Managing Keys

  • Default key: Set one key as default for the project
  • Multiple keys: Create separate keys for different applications or environments
  • Revocation: Delete keys that are no longer needed

Example Usage

Use your API key to access Daft Cloud models from your local machine:
import os
import daft
from daft.functions import prompt, embed_text

# Configure Daft to use your API key
daft.set_provider(
    "openai",
    base_url="https://inference.daft.ai/v1",
    api_key=os.getenv("DAFT_API_KEY"),
)

# Now use Daft Cloud models in your code
df = daft.from_pydict({
    "input": [
        "What sound does a cat make?",
        "What sound does a dog make?",
        "What sound does a cow make?",
        "What does the fox say?",
    ]
})

# Generate responses using a chat model
df = df.with_column("response", prompt(df["input"], model="Qwen/Qwen2.5-0.5B-Instruct"))

df.show()
Set your API key as an environment variable before running:
export DAFT_API_KEY="sk-..."
See the full list of available models at cloud.daft.ai/models/all. Learn more about Daft’s AI function in the Daft documentation.

Usage Tracking

All inference calls made with your API key are tracked:
  • Token usage (input/output)
  • Request counts
  • Associated costs
View usage in the Usage section of your project dashboard.

Security Best Practices

  • Never commit API keys to version control
  • Use environment variables to store keys in your applications
  • Rotate keys periodically for security
  • Use separate keys for development and production
  • Delete unused keys promptly