Back to Blog

DeepSeek Harness Custom Model Provider: API Setup Guide

Tutorials and Guides8456
DeepSeek Harness Custom Model Provider: API Setup Guide

An AI agent can have a well-designed interface, a useful collection of plugins, and access to local tools. Yet its capabilities still depend heavily on the model behind the agent runtime.

This becomes clear when developers start experimenting with different model providers.

One model may perform well on code generation. Another may be more suitable for long-context analysis. A third may offer a better cost profile for routine tasks.

If every model requires a separate application or an entirely different agent configuration, switching becomes inconvenient.

DeepSeek Harness provides a custom model API configuration option that addresses this requirement.

Developers can define a custom provider with a provider identifier, base URL, API protocol, credential, and model list.

The configuration is more flexible than simply entering an API key. It also requires an understanding of the protocol used by the selected endpoint.

This guide explains how to configure a custom provider, discover available models, troubleshoot compatibility issues, and organize multiple model connections.

1. Understand the Provider Architecture

DeepSeek Harness separates the agent runtime from its model provider.

The runtime manages agent execution, tools, conversations, and other application components.

The provider handles model requests.

A simplified architecture looks like this:

text
DeepSeek Harness
       |
       v
Provider Configuration
       |
       +---- Provider A
       |
       +---- Provider B
       |
       +---- Provider C
       |
       v
Selected Model API
       |
       v
Model Response
       |
       v
Agent Runtime

This separation is useful because the same agent environment can work with different model backends.

However, different providers may use different API protocols.

That is why the protocol selection field matters.

2. Understand the Four API Protocol Options

The official DeepSeek Harness provider documentation describes four protocol options:

ProtocolInternal configuration value
OpenAI Chat Completionsopenai-completions
OpenAI Responsesopenai-responses
Anthropic Messagesanthropic-messages
Gemini APIgoogle-generative-ai

These are not simply different names for the same interface.

Each protocol has its own request structure, authentication conventions, and response format.

For example, an OpenAI Chat Completions request generally uses:

json
{
  "model": "MODEL_ID",
  "messages": [
    {
      "role": "user",
      "content": "Explain this code."
    }
  ]
}

An Anthropic Messages request has a different structure:

json
{
  "model": "MODEL_ID",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "Explain this code."
    }
  ]
}

Although these examples look similar, their complete API specifications are not interchangeable.

The application must select the protocol that the endpoint actually supports.

3. Add a Custom Model Provider

Open DeepSeek Harness and navigate to:

text
Settings
   |
   v
Models
   |
   v
Custom Model API

The custom provider form requires several fields.

FieldPurpose
Provider IDInternal provider identifier
Display NameName shown in the interface
Base URLAPI endpoint
API ProtocolRequest protocol
API KeyAuthentication credential
Model IDActual model identifier

A sample configuration might look like this:

yaml
provider:
  id: company-gateway
  name: Company Gateway
  base_url: https://gateway.example/v1
  protocol: openai-completions
  api_key: ${GATEWAY_API_KEY}

models:
  - id: deepseek-flash
    name: DeepSeek Flash

This is an illustrative representation of the configuration fields, not a complete replacement for the application's generated configuration file.

The actual UI should be used to create and save the provider.

4. Why Provider ID Must Be Chosen Carefully

Provider ID is more important than its display name.

DeepSeek Harness uses the provider identifier in requests, saved sessions, model defaults, and credential references.

According to the official documentation, the ID is permanent after creation.

If you want to rename a provider, the documented process is to create a new provider and remove the old one.

This creates an important configuration consideration.

Avoid using temporary names such as:

text
test1
provider-new
model-temp

Instead, choose identifiers that describe the actual connection:

text
company-gateway
deepseek-production
research-models
internal-inference

A stable naming convention becomes increasingly useful when several teams share the same Harness environment.

5. Model Discovery: Why Automatic Fetching Sometimes Fails

After configuring the endpoint, developers can use the model discovery feature.

The application sends a request to the configured endpoint and attempts to retrieve the available models.

This is convenient when the endpoint supports a recognized model-list format.

However, automatic discovery is not guaranteed to work with every gateway.

Some API services expose different model-list structures. Others may require permissions that the current key does not have.

The official Harness documentation explains that developers can add model identifiers manually if automatic discovery fails.

This is an important distinction.

A failed model-discovery request does not necessarily mean inference is unavailable.

The two operations should be tested separately.

For example:

bash
curl --fail-with-body \
  "https://gateway.example/v1/models" \
  -H "Authorization: Bearer $GATEWAY_API_KEY"

If the endpoint does not return a model list in the expected format, record the actual model identifier from the provider documentation and configure it manually.

Then submit a small inference request to verify compatibility.

6. Configure Model Metadata Correctly

A model's name is not the only information the agent runtime may need.

The provider configuration can also contain metadata such as:

Incorrect metadata can create problems even when the endpoint accepts basic requests.

For example, an application may believe a model supports image input when the selected model deployment only accepts text.

A more complete configuration should distinguish model capabilities:

yaml
models:
  - id: deepseek-flash
    name: DeepSeek Flash
    context_window: 1048576
    input_types:
      - text
    max_output_tokens: 8192

The numbers above are illustrative configuration examples. Use the actual model documentation for context and output limits rather than copying these values into production without verification.

For multimodal models, explicitly validate image, audio, and video support.

Do not infer these capabilities from the provider name.

7. Store API Credentials Safely

An important design feature in DeepSeek Harness is that saved credentials are treated as write-only values in the documented provider configuration workflow.

The credential is stored separately from the general settings reference.

The documentation describes the following locations:

text
$DSH_HOME/.credentials.yaml

and the active profile configuration:

text
$DSH_HOME/profiles/<profile>/cordis.patch.yml

The credential reference and provider settings have different responsibilities.

This separation is useful for preventing secrets from being exposed in ordinary configuration displays.

For production environments, access to the credential storage location should still be restricted.

Use appropriate file permissions and secret-management procedures.

Do not commit credential files to Git.

A .gitignore entry can help prevent accidental inclusion:

gitignore
.credentials.yaml
.env
.env.*

Remember that .gitignore only prevents certain untracked files from being added automatically. It does not remove secrets already committed to repository history.

8. Configure Multiple Providers for Different Workloads

A common mistake is configuring every model under one provider without considering the actual application requirements.

A more structured design separates connections by protocol or operational purpose.

For example:

ProviderProtocolWorkload
deepseek-mainOpenAI Chat CompletionsGeneral coding
claude-toolsAnthropic MessagesTool-oriented tasks
gemini-analysisGemini APIMultimodal analysis
internal-modelsOpenAI ResponsesInternal applications

This structure makes the model picker easier to manage.

There is also an important protocol rule in the official documentation: one provider speaks one protocol.

If a gateway exposes multiple API protocols, create separate provider configurations for the different interfaces.

Do not assume that one provider declaration can transparently switch between protocols.

9. What Happens When You Switch Models?

Model selection and conversation history are separate concerns.

DeepSeek Harness documentation explains that selecting a model changes the default for new sessions. A session that has already sent a request retains the model recorded in its own log.

This behavior is important when testing model differences.

Suppose you open a session using one provider, then change the default model in Settings.

The existing conversation should not automatically be assumed to have migrated.

For a clean comparison, create separate sessions.

For example:

text
Test A:
Provider: deepseek-main
Model: deepseek-flash

Test B:
Provider: company-gateway
Model: alternate-model

Use the same prompt, project files, and evaluation criteria.

This makes it easier to compare response quality, tool execution, and latency without confusing results from different model configurations.

10. Troubleshoot Common Provider Errors

Error or symptomPossible explanationWhat to check
MISSING_CREDENTIALMissing stored credentialSave the key or configure its environment reference
UNKNOWN_MODELModel not configuredAdd the exact model ID
Fetch models returns 401Credential rejectedVerify key and endpoint
Model list is emptyUnsupported listing formatAdd model IDs manually
Provider cannot connectWrong Base URLCheck endpoint and path
Model accepts text but not imagesUnsupported input typeVerify model capabilities
Existing session uses old modelSession retains its original modelStart a new session

A useful debugging rule is to isolate the provider layer from the agent layer.

First, verify the endpoint with a small direct API request.

Next, verify the provider configuration.

Finally, test the complete Harness workflow.

This sequence prevents developers from repeatedly changing agent plugins when the actual issue is an incorrect API protocol.

11. Connect a Centralized API Gateway

When an organization needs several model families, maintaining separate credentials and provider configurations can become cumbersome.

A centralized API gateway offers a way to organize supported model connections behind a consistent entry point.

For example, 4SAPI can be evaluated as a unified API gateway for supported models.

The Harness custom provider workflow is particularly relevant because developers can configure the gateway's base URL, credential, protocol, and model IDs.

Before deployment, verify the following:

  1. The selected gateway endpoint supports the chosen protocol.
  2. The model identifier matches the gateway's model catalog.
  3. The API key belongs to that gateway.
  4. The model supports the capabilities expected by Harness.
  5. Tool calls and streaming work as required by the agent.
  6. Usage can be monitored independently from the local agent runtime.

A gateway centralizes access, but it does not make every underlying model behave identically.

Application developers must still account for model-specific context limits, tool schemas, and response formats.

12. A Practical Provider Validation Procedure

Before adding a provider to a shared environment, complete a small validation exercise.

text
Step 1: Confirm endpoint
        |
Step 2: Validate credential
        |
Step 3: Check protocol
        |
Step 4: Verify model ID
        |
Step 5: Send basic request
        |
Step 6: Test streaming
        |
Step 7: Test tool execution
        |
Step 8: Test a new session

Keep the results in a provider inventory.

A simple table can record:

FieldExample
Provider IDcompany-gateway
ProtocolOpenAI Chat Completions
Model IDdeepseek-flash
AuthenticationAPI key
Basic inferencePassed / Failed
StreamingPassed / Failed
Tool callingPassed / Failed
Last validationDate

This is more useful than relying on a note that says a model was configured successfully several months ago.

Conclusion

DeepSeek Harness's custom provider functionality makes it possible to connect different model backends without rebuilding the entire agent environment.

However, successful configuration requires more than entering an API key.

Provider ID, endpoint, protocol, model identifier, credential storage, and model metadata all influence whether the integration works as expected.

For developers building multi-model agents, the most important principle is to treat the model provider as an independent integration layer.

Validate that layer first, then test the complete agent workflow.

This approach makes model switching easier to understand, troubleshoot, and maintain as the application grows.

References and further reading

  1. DeepSeek Harness Official Provider Configuration
  2. DeepSeek Harness GitHub Repository
  3. DeepSeek API Documentation
  4. OpenAI API Reference
  5. Anthropic API Documentation
  6. Google Gemini API Documentation

Related articles

Tags:DeepSeek Harness custom model providerDeepSeek Harness custom APIDeepSeek Harness OpenAI compatible APIDeepSeek Harness model configuration

Recommended reading

Explore more frontier insights and industry know-how.