Use Dify with a private API

Connect Dify to the private Morse API: set it up, pick a model, and check it works.

Give Dify the base URL https://inference.trymorse.ai/v1 and a Morse API key. It calls the OpenAI API.

Before you start

Make a key for Dify alone, with a spend limit, under API keys in the console. Then one tool can't spend all your credits. See Limit a key.

You'll paste the key into Dify's model provider settings.

Set up Dify

  1. Install the OpenAI-API-compatible provider

    In Dify, open Settings > Model Provider. Install OpenAI-API-compatible from the Marketplace.

  2. Add a Morse model

    On OpenAI-API-compatible, choose Add Model, and fill in:

    • Model Name: qwen/qwen3-coder
    • API Key: your key
    • API Base URL: https://inference.trymorse.ai/v1
    • Completion mode: Chat
    • Model context size: 262144
    • Function Call Type: Tool Call, so agents can send tools
    • Vision Support: Not Support

    Leave API Type at Chat Completions API. Save, and Dify checks the model.

  3. Use it in an app

    In a chatbot, agent, or workflow, pick qwen/qwen3-coder under OpenAI-API-compatible in the model menu. Add each model you want the same way.

Which model to pick

ModelContextInput / outputWhy
qwen/qwen3-coder262.1K$0.375 / $1.25Qwen's coding model. It doesn't reason, so it starts writing sooner.
moonshotai/kimi-k3.1-pro1M$2 / $10Reasons, and reads images.
z-ai/glm-5.31M$1.40 / $4.40Reasons, and takes tools at TEE too.
deepseek/deepseek-v4-pro-08131M$1.32 / $3.96Reasons, at a lower price.
z-ai/glm-5.3-flash1M$0.15 / $0.50Cheap and fast for small edits, and takes tools at TEE too.

Prices are in dollars per million tokens, on each model's default endpoint. Every model is on the models page.

Check it works

Saving the model sends Morse a short request with your key. Dify saves the model only when Morse returns a response, and shows Morse's error when it doesn't.

Keep it private

Set a privacy floor on Dify's key to hold it to a tier, such as TEE. Without a floor, a request runs on its model's default privacy tier. The floor only decides which endpoints serve the requests. See Privacy tiers and Provider routing.

On a plain API call, TLS ends inside Morse's door, an attested enclave, which seals the request before the relay receives it. A plain client checks the door's certificate, not its attestation. To check the attestation yourself, see Sealed API keys.

If something goes wrong

What you seeWhat to do
A knowledge base asks for an embedding modelMorse serves no embeddings. Choose the Economical index, or add an embedding model from another provider.
401 invalid_api_keyCheck the key you gave Dify in full, and that it isn't revoked.
402 insufficient_balance or key_spend_limit_reachedAdd credits, or raise the key's spend limit. A request holds credit for its output limit before it starts: see Holds.
404 model_not_foundUse a model's id exactly as the table above writes it, with the part before the slash.

Every code is in Error codes. For other tools, see Tools and coding agents.