AI Art Engine 中文
Menu

Guide · NewAPI

Connecting to NewAPI

NewAPI is an open-source OpenAI-compatible relay that puts many channels' models behind one address. This app ships a built-in NewAPI provider: text goes to /chat/completions, images go to /images/generations, and it reads the gateway's public endpoint metadata to sort models into the Text and Image tabs automatically.

1. How it connects

Settings → Models → Add model provider → pick NewAPI: enter your gateway address and NewAPI token. There is no endpoint type to choose.

Scenario API Base URL API Key
Hosted NewAPI https://your-newapi.example.com/v1 Required (a NewAPI token starting with sk-)
Self-hosted NewAPI http://127.0.0.1:3000/v1 Required (same)
The Base URL must include /v1 yourself. The app only strips a trailing slash; it never appends /v1 for you. Enter https://your-newapi.example.com/v1 and requests go to https://your-newapi.example.com/v1/chat/completions. If NewAPI lives under a sub-path, put the sub-path in too, e.g. https://your-newapi.example.com/gateway/v1.
Capability Actual request Model catalog
Text POST {Base URL}/chat/completions Fetched from GET {Base URL}/models; image-capable models never show up here
Image POST {Base URL}/images/generations; with a reference image, POST {Base URL}/images/edits (multipart, one image max) Listed automatically from the gateway's endpoint metadata; falls back to id-name heuristics when metadata is unavailable, and you can still add ids by hand

The endpoint metadata comes from the gateway's public GET /api/pricing, which carries an endpoint dictionary mapping endpoint types to real paths:

{
  "image-generation": { "path": "/v1/images/generations" },
  "image-edit":       { "path": "/v1/images/edits" },
  "openai":           { "path": "/v1/chat/completions" }
}

Each model entry also carries supported_endpoint_types, so “can this model generate images” does not rely on guessing names (even something like grok-imagine-image is detected). The list of models still comes from the token-visible /v1/models — metadata only decides modality and endpoint, it never adds models your token cannot use.

The NewAPI provider has only two tabs: Text and Image. Video / audio / 3D model nodes cannot select it; even if a model id gets in by other means, execution fails with “video generation / speech synthesis / 3D model generation is not supported yet”.

2. Prepare three things on the NewAPI side

  1. The site address: the domain you normally open the NewAPI panel on (this guide uses https://your-newapi.example.com as a placeholder — substitute your own site). Its OpenAI-compatible entry point is /v1, so the Base URL is https://your-newapi.example.com/v1.
  2. A token: NewAPI panel → Tokens → add a token, then copy the string starting with sk-. The token's group decides which models you can use — this is the easiest trap:
    The catalog the app fetches is GET /v1/models, which only lists models available to your token's group; the panel's price list (/pricing, GET /api/pricing) lists every group on the site, so the two counts often differ.
    Typical: the price list has 13 models while the token catalog has 3 — the other 10 sit in other groups (such as GPT-Image-4K, Nano Banana, Grok-imagine-image) and calling them with this token returns 503: No available channel for model … under group GPT-Image.
    To use those models, switch the token to a group that covers them, or create a token for that group.
  3. Model names: NewAPI panel → Channels / Models, and note the exact model ids you want (such as gpt-4o-mini, deepseek-chat, flux.1-schnell, gpt-image-2.5-flare). When typing a model by hand it must match character for character, including case and hyphens.

Before filling anything into the app, confirm these endpoints work from a shell:

# model list (token-visible catalog + auth check)
curl -H "Authorization: Bearer sk-YOUR-TOKEN" https://your-newapi.example.com/v1/models

# text completion
curl -X POST https://your-newapi.example.com/v1/chat/completions \
  -H "Authorization: Bearer sk-YOUR-TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"hi"}]}'

# image generation (use an image model id from your catalog)
curl -X POST https://your-newapi.example.com/v1/images/generations \
  -H "Authorization: Bearer sk-YOUR-TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-image-2.5-flare","prompt":"a red ball","n":1}'

3. Add the NewAPI provider in this app

  1. Open Settings → Models (models and keys are global, shared by every project).
  2. In the “Add model provider” dropdown pick NewAPI, then click Add. The new card expands and scrolls into view automatically.
  3. Display name: the default NewAPI is fine, or rename it to your site.
  4. API Base URL: replace the placeholder with your own gateway, e.g. https://your-newapi.example.com/v1 (see the reminder in section 1).
  5. API Key: paste the NewAPI token. The eye button reveals it temporarily so you can double-check.
  6. Tick Enabled — a disabled provider never shows up in any node's model dropdown.
There is nothing to save: settings persist automatically after a 500 ms debounce. The built-in NewAPI provider has no endpoint type to choose (it always speaks the OpenAI-compatible protocol) and no central sign-up page — you create tokens in your own gateway's panel.

4. Fetch text models

  1. Switch to the Text tab.
  2. Click Fetch available models. The button briefly reads “Verifying API key…” — that step doubles as the key and connectivity check.
  3. On success the count appears next to the button. The list is filtered by modality: image-capable models are sorted into the Image tab and never show up here.
  4. Use the filter box and “Select all in list” / “Clear selection”, then tick your models.
  5. To pin a default, pick one in the Default generation model dropdown (it lists only the ticked models).

Editing a generation node now shows NewAPI · model name in the model dropdown. If the dropdown is empty the inspector says “configure an available text model in settings first (an API key plus at least one ticked model)” — come back to this step.

If the fetch returns nothing at all, your token's group has no chat channel (it is not an address or key problem): the app then says “all models returned are image-generation models”. Tick them on the Image tab instead.

5. Adding models by hand (the important part)

Every provider card has a free-text field labelled “Model / endpoint / Resource ID (type it in)” with an “Add & select” button next to it (Enter works too). Type an id, click the button, and the model joins the current tab's list already ticked; the field clears itself afterwards.

The field is per tab. An id typed on the Text tab only lands in the text list, and one typed on the Image tab only lands in the image list — the two do not share input. Do not type an image model on the Text tab.

5.1 When you have to type it by hand

  • Image models usually need no hand-typing. Fetching reads the gateway's endpoint metadata and puts image-capable models on the Image tab (see section 1). You only type them when that metadata is unavailable or when an id gives no hint of being an image model — hand-typed entries merge into the same list as fetched ones.
  • Fetching returns 404 / 405: the gateway does not implement /models. The list comes back empty without an error (expected). Type the ids instead — generation is unaffected.
  • “All N models returned by the endpoint are image-generation models”: the token's group only has image channels, so the Text tab has nothing to show — tick them on the Image tab, or switch the token to a group that includes chat channels.
  • Fetching reports “the gateway returned no models”: the address or token is wrong, or the token is not bound to any channel.
  • You only want a few: skip scrolling through hundreds of models and type the ids you need.
  • A model was renamed on NewAPI: type the new id; un-tick the stale entry.

5.2 Typing a text model

  1. Stay on the Text tab.
  2. Type the exact model id from NewAPI into the “model / endpoint / Resource ID” field, for example deepseek-chat.
  3. Click Add & select (or press Enter).
  4. Optionally set it as the default in “Default generation model”.

5.3 Typing an image model

  1. Switch to the Image tab and click Fetch available models once — normally the image-capable models are listed right away (the image catalog is picked by gateway endpoint metadata, not hard-wired to be empty).
  2. For anything not listed, type the image model id into the field, for example gpt-image-2.5-flare or flux.1-schnell. Use a name that really exists on NewAPI — not a description such as “image model”.
  3. Click Add & select.
  4. Make it the default in the “Default generation model” dropdown (ticked entries only).
If the Image tab comes back empty even though your token's group does have image channels, read the note again: “The remote returned an empty list; the previous result was kept. Try again later.” means the gateway catalog held no model that could be classified as an image model — type the id by hand. Not a failure, and your hand-typed entries are not lost.

5.4 Are hand-typed entries ever overwritten?

  • No. When you fetch again, models that are ticked but absent from the remote catalog are kept and added back to the list (an occasionally empty remote list also keeps the previous result).
  • Duplicate ids are not added twice — an id already in the list is simply re-ticked.
  • Only ticked models are persisted. Ticking writes them into the settings file; un-ticking removes the model together with its capability snapshot.
  • Only ticked models can be picked in nodes. A node's dropdown lists ticked entries only; if a model id reaches a node by another route (MCP, a template, an older project) without being ticked here, execution silently falls back to the default model or the first ticked one.

6. Using it in nodes

  1. Text generation node: pick NewAPI · your text model in the model dropdown, write an instruction, run it.
  2. Image generation node: pick NewAPI · your image model. To use a reference image, wire an image into that node's image input — with a reference present the request switches to /images/edits.
  3. Resolution and quality: the request carries size / quality / n when applicable; size is sent only when it maps to 1024x1024 / 1536x1024 / 1024x1536, otherwise it is omitted. Some relayed models accept only their own sizes — when a request fails, check the actual request in the run log first.
  4. Progress and failure reasons live in the run log; authentication failures come with “check that the API key in settings is correct and saved, and that the provider Base URL matches”.

7. FAQ

  • “Fetch available models” is greyed out: the NewAPI provider needs a token before that button enables. Fill in the token (and make sure Enabled is ticked).
  • “Invalid API key, model fetching blocked: …”: the key was copied wrong, the token is disabled or expired, or its group is not allowed for this request.
  • “Connection test failed: code=ENOTFOUND …”: the domain does not resolve — a typo, or a local network or proxy problem. A domain that opens in a browser is not proof: the app connects from the main process and does not use system proxy settings.
  • Fetching returns 404 / 405, or an empty list: the gateway has no /models. Type the model ids as in section 5; generation still works.
  • The panel price list shows a dozen models but the app only fetches a few: the app reads GET /v1/models, which only lists models available to your token's group; the panel price list covers every group on the site. Switch the token's group (see section 2) to reach the others.
  • Fetching or generating returns 503 / No available channel: that model has no usable channel under your token's group — not a bug in the app. Switch groups, or use another model in the same group.
  • The Text tab has no models at all while Image does: the token's group only has image channels. That is expected, and the app says so: “all models returned are image-generation models”.
  • The Image tab fetch says “the remote returned an empty list; the previous result was kept”: the gateway catalog held no classifiable image model. Type the id by hand — not a failure, and your entry stays.
  • Generation fails with “video generation / speech synthesis / 3D model generation is not supported yet”: the NewAPI provider only does text and images. For video use a built-in video provider or ComfyUI (see the ComfyUI guide).
  • Classic wrong-Base-URL symptoms: omitting /v1, or including /chat/completions as well, both end in 404.
  • Model name does not match: always copy the id shown in the NewAPI panel and check it character by character; relays often add prefixes or suffixes such as -free, -thinking or -4k.
  • Where is the API key stored: in the local settings file (on Windows, for example, %APPDATA%\AIArtEngine\aiartengine-settings.json), in plain text. It is never uploaded to the app's own servers, but do take care of that file on this machine.

Further reading: NewAPI docs · Manual · Settings.