---
updatedAt: 2026-10-07T02:03:31.000Z
agentTools:
  projectIndex: https://docs.logmeal.com/llms.txt
---

# Best Practices & Toubleshooting

## Do's and Don'ts

> This guide provides **best practices** for integrating the Food AI Engine API.\
> Follow these recommendations to ensure your applications are **stable, reliable, and efficient**.

***

### ✅ Do's

* **Use the correct user <Glossary>token</Glossary>**\
  Endpoints require specific user types:
  * ⚫ **<Glossary>APICompany</Glossary>** → company-level management
  * 🔴 **<Glossary>APIUser</Glossary>** → individual food <Glossary>recognition</Glossary> and logging
  * 🔵 **<Glossary>APIUserManager</Glossary>** → clinicians or managers supervising multiple users\
    See [Users Types & Access Tokens](./guides-essential-concepts-users-and-access-tokens) for details.

* **Preprocess images**\
  Clean, cropped, and well-lit images improve <Glossary>recognition</Glossary> accuracy.\
  → See [Image Preprocessing](./guides-essential-concepts-image-pre-processing).

* **Monitor quotas programmatically**\
  Use [GET /v2/info/limitations](https://docs.logmeal.com/reference/get_v2-info-limitations#/) to check:
  * <span style={{color:"red", fontSize:"1.8em", fontWeight:"bold"}}>©</span> Monthly <Glossary>credits</Glossary>
  * <span style={{color:"orange", fontSize:"1.2em", fontWeight:"bold"}}>(D)</span> <Glossary>Daily request limits</Glossary>
  * <span style={{color:"purple", fontSize:"1.2em", fontWeight:"bold"}}>(S)</span> <Glossary>Per‑second request limits</Glossary>

* **Handle <Glossary>rate limit</Glossary>s gracefully**\
  If you hit **429 Too Many Requests**, implement **exponential backoff** and respect any `Retry-After` headers.

***

### ❌ Don'ts

* **Don’t share 🔴 <Glossary>APIUser</Glossary> tokens**\
  Each end user must have their own <Glossary>token</Glossary> for correct intake <Glossary>history</Glossary> and nutrition tracking.

* **Don’t ignore request limits**\
  Persistent 429 errors without backoff can temporarily block your app.

* **Don’t hardcode nutritional data**\
  Models and databases evolve. Always fetch fresh data from the API.

* **Don’t upload oversized images**\
  Large files waste bandwidth and <Glossary>credits</Glossary>. Use recommended dimensions.

* **Don’t use deprecated endpoints**\
  Check the [API Documentation](https://docs.logmeal.com/reference/getting-started#/) to stay up-to-date with supported endpoints.

***

### Reliability Best Practices

Design your integration with **fault tolerance** in mind:

* **Retry transient failures**\
  Implement retries with exponential backoff for **429** (<Glossary>rate limit</Glossary>) and **5xx** (server errors).

* **Optimize image payloads**\
  Compress and resize images before sending.

* **Validate inputs**\
  Check image format, size, and parameters before making requests to avoid unnecessary failures.

***

### Common Error Scenarios

Whenever the Food AI Engine API raises an exception, the JSON response will include a custom error code and a descriptive message. We encourage you to inspect these error messages to better understand what went wrong. For example:

```commandline
HTTP status code: 400 (BAD REQUEST)
JSON CONTENT:
{
    "code": 708,
    "message": "Parameter language is not valid. Valid values are {'ger': 'german', 'tur': 'turkish', 'ita': 'italian', 'nld': 'dutch', 'spa': 'spanish', 'fre': 'french', 'eng': 'english', 'cat': 'catalan', 'gre': 'greek', 'heb': 'hebrew'}"
}
```

Below is a list of the most common HTTP error messages you might encounter:

| Error                         | Cause                                      | Resolution                                                                   |
| ----------------------------- | ------------------------------------------ | ---------------------------------------------------------------------------- |
| **429 Too Many Requests**     | <Glossary>Rate limit</Glossary> exceeded   | Backoff + retry later                                                        |
| **400 Bad Request**           | Invalid payload                            | Validate image, parameters, and fields                                       |
| **401 Unauthorized**          | Invalid/expired <Glossary>token</Glossary> | Make sure you are using the appropriate user <Glossary>token</Glossary> type |
| **500 Internal Server Error** | Temporary backend issue                    | Retry with exponential backoff                                               |

***

## 🔧 Troubleshooting

> This guide provides solutions to **common issues** when using the Food AI Engine API and answers frequently asked questions.

### 1. I get **HTTP 401 Unauthorized**

* Cause: Invalid, expired, or missing <Glossary>token</Glossary>.
* Fix: Ensure you are using the correct <Glossary>token</Glossary> type (⚫, 🔴, 🔵) and that it has not expired.
* Solution: Make sure you are using the appropriate <Glossary>token</Glossary> and [generate the adequate <Glossary>token</Glossary>](./guides-essential-concepts-users-and-access-tokens) if necessary.

***

### 2. I get **HTTP 429 Too Many Requests**

* Cause: Exceeded daily (D) or per-second (S) request limits. Or exceeded monthly <Glossary>credits</Glossary> usage if using the 🆓 Free trial plan.
* Fix: Implement exponential backoff retries.
* Solution: Check your quotas with [GET /v2/info/limitations](https://docs.logmeal.com/reference/get_v2-info-limitations#/).

***

### 3. I get **HTTP 400 Bad Request**

* Cause: Invalid request payload (e.g., wrong parameters, unsupported image format, missing fields).
* Fix: Validate inputs before calling the API.
* Tip: Use JPEG images within recommended size limits. See [Image Pre-processing](./guides-essential-concepts-image-pre-processing).

***

### 4. I get **HTTP 500 Internal Server Error**

* Cause: Temporary server-side issue.
* Fix: Retry with exponential backoff. If persistent, <Anchor target="_blank" href="https://logmeal.com/contact/">contact support</Anchor>.

***

### 5. I uploaded an image but no dishes were recognized

* Possible reasons:
  * Poor image quality (blurry, low light).
  * Dish / food item not yet supported in the <Glossary>recognition</Glossary> model.
* Fix: Improve image preprocessing or check if dish is in the [supported list](./guides-essential-concepts-recognition-capabilities).

***

## ❓ FAQs

### Q: Can I test all features without a paid plan?

Yes. The **<Glossary>Free (Trial)</Glossary> tier** provides 30 days of unlimited access to all endpoints.\
After that, you’ll need to subscribe to <span style={{color:"#FFC933", fontWeight:"bold"}}><Glossary>Analyse</Glossary></span>, <span style={{color:"#6FB3E7", fontWeight:"bold"}}><Glossary>Monitor</Glossary></span>, <span style={{color:"#7EDC7B", fontWeight:"bold"}}><Glossary>Recommend</Glossary></span>, or <span style={{color:"#F08A05", fontWeight:"bold"}}><Glossary>Custom</Glossary></span>. See [Plans & Limits](./guides-essential-concepts-plans-limits).

***

### Q: Do I need a new 🔴 <Glossary>APIUser</Glossary> <Glossary>token</Glossary> for each end user?

Yes. Each final user must have their own 🔴 **<Glossary>APIUser</Glossary>** <Glossary>token</Glossary> to ensure personalized nutrition tracking and intake <Glossary>history</Glossary>.

***

### Q: Can managers or clinicians see multiple users’ data?

Yes. Use 🔵 **<Glossary>APIUserManager</Glossary>** tokens. They allow authorized professionals to view and manage multiple users’ intake <Glossary>history</Glossary>.

***

### Q: How do I know which plan I need?

Check the [Plans & Limits](./guides-essential-concepts-plans-limits) guide.

* <span style={{color:"#FFC933", fontWeight:"bold"}}><Glossary>Analyse</Glossary></span> → basic food <Glossary>recognition</Glossary> and nutrition.
* <span style={{color:"#6FB3E7", fontWeight:"bold"}}><Glossary>Monitor</Glossary></span> → <Glossary>history</Glossary>, goals, and company tools.
* <span style={{color:"#7EDC7B", fontWeight:"bold"}}><Glossary>Recommend</Glossary></span> → advanced AI scoring and recommendations.
* <span style={{color:"#F08A05", fontWeight:"bold"}}><Glossary>Custom</Glossary></span> → enterprise features (e.g., Kiosk).

***

### Q: How often are recognition models updated?

Regularly. Updates include new dishes, improved accuracy, and nutritional refinements.

***

### Q: What image formats are supported?

Only JPEG is supported. Use clear, well-lit photos for best results.

***

## Versioning & Deprecations

The Food AI Engine API evolves constantly. New food recognition models are released, endpoints may be improved, and older ones may eventually be deprecated.\
This page explains how to manage **model versions** and what to expect when something is marked as **deprecated**.

***

### Model Versioning

Most <Glossary>recognition</Glossary> endpoints include an optional parameter: `model_version`.

* **By default** → If you do not specify `model_version`, your requests will automatically use the **latest available model**.\
  → This is the **recommended approach** to always benefit from the most up-to-date recognition improvements.

* **When to specify `model_version`** → You may choose to lock to a specific model version if:
  * You need **full reproducibility** of results in a research setting.
  * You are conducting long-term studies where results must remain consistent.
  * You are validating against a fixed dataset and want to avoid mid-study model updates.

> ⚠️ **Note:** Sticking to a fixed `model_version` means you **will not get improvements** (accuracy, new dishes, updated nutrition data) until you explicitly upgrade.

For more details on recognition capabilities, see [Food <Glossary>Recognition</Glossary> Capabilities](./guides-essential-concepts-recognition-capabilities).

***

### Deprecations

Over time, older endpoints or parameters may be **deprecated**.\
This means they are still available for now, but will eventually be removed.

When an endpoint or parameter is deprecated:

* It will be clearly marked in the [API Documentation](https://docs.logmeal.com/reference/getting-started#/).
* A transition period will be provided before removal.

#### Migration Tips

* Always prefer the **latest endpoints** listed in the docs.
* Update your integrations promptly when a deprecation notice is published.

***

### Best Practices

* **Default to latest models** → Don’t set `model_version` unless reproducibility is critical.
* **Test regularly** with fresh data when new models are released.
* **Design for flexibility** so you can update `model_version` or endpoint paths with minimal code changes.

***

## Related Resources

* [Plans & Limits](./guides-essential-concepts-plans-limits) → Learn how quotas and <Glossary>credits</Glossary> work
* [User Types & Access Tokens](./guides-essential-concepts-users-and-access-tokens) → Learn about Food AI Engine API user types and how their access tokens control endpoint permissions.