# Create a MandAPI model profile for Junie CLI

Use Junie's custom JSON profiles with a complete Chat Completions request URL.

## Choose the API format

Junie CLI supports custom model profiles. Choose an account-visible MandAPI model with reliable tool calling for the coding work you need. This recipe uses Chat Completions, not JetBrains' Ingrazzio proxy protocol.

Junie's `baseUrl` is the complete request URL: it does not append an API path. For `OpenAICompletion`, use `https://api.mandapi.com/v1/chat/completions` rather than stopping at `/v1`.

## Create a named profile

Create `.junie/models/mandapi.json` in your project, or put `mandapi.json` in your configured `$JUNIE_HOME/models` directory. Replace `MODEL_ID` with the exact ID accepted by your account:

```json
{
  "displayName": "MandAPI",
  "providerName": "MandAPI",
  "baseUrl": "https://api.mandapi.com/v1/chat/completions",
  "id": "MODEL_ID",
  "apiType": "OpenAICompletion",
  "apiKey": "${MANDAPI_API_KEY}"
}
```

The filename supplies the profile name. The environment reference keeps a real credential out of the JSON. No helper model override is needed for this starting setup: omitted roles inherit the top-level model.

## Supply the key and start

Set `MANDAPI_API_KEY` privately in the terminal that will launch Junie. In Bash:

```bash
read -rsp "MandAPI key: " MANDAPI_API_KEY
printf '\n'
export MANDAPI_API_KEY
```

Or PowerShell:

```powershell
$env:MANDAPI_API_KEY = [Net.NetworkCredential]::new('', (Read-Host 'MandAPI key' -AsSecureString)).Password
```

```bash
junie --model custom:mandapi
```

Ask for a README summary without changing files. Confirm the selected custom profile and check the corresponding usage in MandAPI before starting a larger coding task.

## Fix the precise error

A missing environment variable can prevent the profile loading. A 404 can mean the profile used only a base host instead of the full request path. If the profile is absent, check its filename, JSON syntax and model discovery directory. Repeated malformed tool calls call for checking the model's compatibility, not just increasing retries.

To restore the earlier provider, select it with `/model` and remove or rename this profile outside the discovery directory.

## References

- [https://junie.jetbrains.com/docs/custom-llm-models.html](https://junie.jetbrains.com/docs/custom-llm-models.html)
- [https://junie.jetbrains.com/docs/junie-cli.html](https://junie.jetbrains.com/docs/junie-cli.html)
- [https://openrouter.ai/docs/cookbook/coding-agents/junie](https://openrouter.ai/docs/cookbook/coding-agents/junie)
