code: def embedding(
      model,
      input=[],
      # Optional params
      timeout=600,  # default to 10 minutes
      # set api_base, api_version, api_key
      api_base: Optional[str] = None,
      api_version: Optional[str] = None,
      api_key: Optional[str] = None,
      api_type: Optional[str] = None,
      caching: bool = False,
      user: Optional[str] = None,
      custom_llm_provider=None,
      litellm_call_id=None,
      litellm_logging_obj=None,
      logger_fn=None,
      **kwargs,
  ):
      """
      Embedding function that calls an API to generate embeddings for the given input.
  
      Parameters:
      - model: The embedding model to use.
      - input: The input for which embeddings are to be generated.
      - timeout: The timeout value for the API call, default 10 mins
      - litellm_call_id: The call ID for litellm logging.
      - litellm_logging_obj: The litellm logging object.
      - logger_fn: The logger function.
      - api_base: Optional. The base URL for the API.
      - api_version: Optional. The version of the API.
      - api_key: Optional. The API key to use.
      - api_type: Optional. The type of the API.
      - caching: A boolean indicating whether to enable caching.
      - custom_llm_provider: The custom llm provider.
  
      Returns:
      - response: The response received from the API call.
  
      Raises:
      - exception_type: If an exception occurs during the API call.
      """
      azure = kwargs.get("azure", None)
      client = kwargs.pop("client", None)
      rpm = kwargs.pop("rpm", None)
      tpm = kwargs.pop("tpm", None)
      model_info = kwargs.get("model_info", None)
      metadata = kwargs.get("metadata", None)
      encoding_format = kwargs.get("encoding_format", None)
      proxy_server_request = kwargs.get("proxy_server_request", None)
      aembedding = kwargs.get("aembedding", None)
      openai_params = [
          "user",
          "request_timeout",
          "api_base",
          "api_version",
          "api_key",
          "deployment_id",
          "organization",
          "base_url",
          "default_headers",
          "timeout",
          "max_retries",
          "encoding_format",
      ]
      litellm_params = [
          "metadata",
          "aembedding",
          "caching",
          "mock_response",
          "api_key",
          "api_version",
          "api_base",
          "force_timeout",
          "logger_fn",
          "verbose",
          "custom_llm_provider",
          "litellm_logging_obj",
          "litellm_call_id",
          "use_client",
          "id",
          "fallbacks",
          "azure",
          "headers",
          "model_list",
          "num_retries",
          "context_window_fallback_dict",
          "roles",
          "final_prompt_value",
          "bos_token",
          "eos_token",
          "request_timeout",
          "complete_response",
          "self",
          "client",
          "rpm",
          "tpm",
          "input_cost_per_token",
          "output_cost_per_token",
          "hf_model_name",
          "proxy_server_request",
          "model_info",
          "preset_cache_key",
          "caching_groups",
          "ttl",
          "cache",
      ]
      default_params = openai_params + litellm_params
      non_default_params = {
          k: v for k, v in kwargs.items() if k not in default_params
      }  # model-specific params - pass them straight to the model/provider
  
      (
          model,
          custom_llm_provider,
          dynamic_api_key,
          api_base,
      ) = get_llm_provider(
          model=model,
          custom_llm_provider=custom_llm_provider,
          api_base=api_base,
          api_key=api_key,
      )
      optional_params = get_optional_params_embeddings(
          user=user,
          encoding_format=encoding_format,
          custom_llm_provider=custom_llm_provider,
          **non_default_params,
      )
      try:
          response = None
          logging = litellm_logging_obj
          logging.update_environment_variables(
              model=model,
              user=user,
              optional_params=optional_params,
              litellm_params={
                  "timeout": timeout,
                  "azure": azure,
                  "litellm_call_id": litellm_call_id,
                  "logger_fn": logger_fn,
                  "proxy_server_request": proxy_server_request,
                  "model_info": model_info,
                  "metadata": metadata,
                  "aembedding": aembedding,
                  "preset_cache_key": None,
                  "stream_response": {},
              },
          )
          if azure == True or custom_llm_provider == "azure":
              # azure configs
              api_type = get_secret("AZURE_API_TYPE") or "azure"
  
              api_base = (
                  api_base
                  or litellm.api_base
                  or get_secret("AZURE_API_BASE")
              )
  
              api_version = (
                  api_version
                  or litellm.api_version
                  or get_secret("AZURE_API_VERSION")
              )
  
              azure_ad_token = kwargs.pop(
                  "azure_ad_token", None
              ) or get_secret("AZURE_AD_TOKEN")
  
              api_key = (
                  api_key
                  or litellm.api_key
                  or litellm.azure_key
                  or get_secret("AZURE_API_KEY")
              )
              ## EMBEDDING CALL
              response = azure_chat_completions.embedding(
                  model=model,
                  input=input,
                  api_base=api_base,
                  api_key=api_key,
                  api_version=api_version,
                  azure_ad_token=azure_ad_token,
                  logging_obj=logging,
                  timeout=timeout,
                  model_response=EmbeddingResponse(),
                  optional_params=optional_params,
                  client=client,
                  aembedding=aembedding,
              )
          elif (
              model in litellm.open_ai_embedding_models
              or custom_llm_provider == "openai"
          ):
              api_base = (
                  api_base
                  or litellm.api_base
                  or get_secret("OPENAI_API_BASE")
                  or "https://api.openai.com/v1"
              )
              openai.organization = (
                  litellm.organization
                  or get_secret("OPENAI_ORGANIZATION")
                  or None  # default - https://github.com/openai/openai-python/blob/284c1799070c723c6a553337134148a7ab088dd8/openai/util.py#L105
              )
              # set API KEY
              api_key = (
                  api_key
                  or litellm.api_key
                  or litellm.openai_key
                  or get_secret("OPENAI_API_KEY")
              )
              api_type = "openai"
              api_version = None
  
              ## EMBEDDING CALL
              response = openai_chat_completions.embedding(
                  model=model,
                  input=input,
                  api_base=api_base,
                  api_key=api_key,
                  logging_obj=logging,
                  timeout=timeout,
                  model_response=EmbeddingResponse(),
                  optional_params=optional_params,
                  client=client,
                  aembedding=aembedding,
              )
          elif model in litellm.cohere_embedding_models:
              cohere_key = (
                  api_key
                  or litellm.cohere_key
                  or get_secret("COHERE_API_KEY")
                  or get_secret("CO_API_KEY")
                  or litellm.api_key
              )
              response = cohere.embedding(
                  model=model,
                  input=input,
                  optional_params=optional_params,
                  encoding=encoding,
                  api_key=cohere_key,
                  logging_obj=logging,
                  model_response=EmbeddingResponse(),
              )
          elif custom_llm_provider == "huggingface":
              api_key = (
                  api_key
                  or litellm.huggingface_key
                  or get_secret("HUGGINGFACE_API_KEY")
                  or litellm.api_key
              )
              response = huggingface.embedding(
                  model=model,
                  input=input,
                  encoding=encoding,
                  api_key=api_key,
                  api_base=api_base,
                  logging_obj=logging,
                  model_response=EmbeddingResponse(),
              )
          elif custom_llm_provider == "bedrock":
              response = bedrock.embedding(
                  model=model,
                  input=input,
                  encoding=encoding,
                  logging_obj=logging,
                  optional_params=optional_params,
                  model_response=EmbeddingResponse(),
              )
          elif custom_llm_provider == "oobabooga":
              response = oobabooga.embedding(
                  model=model,
                  input=input,
                  encoding=encoding,
                  api_base=api_base,
                  logging_obj=logging,
                  optional_params=optional_params,
                  model_response=EmbeddingResponse(),
              )
          elif custom_llm_provider == "ollama":
              if aembedding == True:
                  response = ollama.ollama_aembeddings(
                      model=model,
                      prompt=input,
                      encoding=encoding,
                      logging_obj=logging,
                      optional_params=optional_params,
                      model_response=EmbeddingResponse(),
                  )
          elif custom_llm_provider == "sagemaker":
              response = sagemaker.embedding(
                  model=model,
                  input=input,
                  encoding=encoding,
                  logging_obj=logging,
                  optional_params=optional_params,
                  model_response=EmbeddingResponse(),
                  print_verbose=print_verbose,
              )
          elif custom_llm_provider == "mistral":
              api_key = (
                  api_key
                  or litellm.api_key
                  or get_secret("MISTRAL_API_KEY")
              )
              response = openai_chat_completions.embedding(
                  model=model,
                  input=input,
                  api_base=api_base,
                  api_key=api_key,
                  logging_obj=logging,
                  timeout=timeout,
                  model_response=EmbeddingResponse(),
                  optional_params=optional_params,
                  client=client,
                  aembedding=aembedding,
              )
          elif custom_llm_provider == "voyage":
              api_key = (
                  api_key
                  or litellm.api_key
                  or get_secret("VOYAGE_API_KEY")
              )
              response = openai_chat_completions.embedding(
                  model=model,
                  input=input,
                  api_base=api_base,
                  api_key=api_key,
                  logging_obj=logging,
                  timeout=timeout,
                  model_response=EmbeddingResponse(),
                  optional_params=optional_params,
                  client=client,
                  aembedding=aembedding,
              )
          elif custom_llm_provider == "xinference":
              api_key = (
                  api_key
                  or litellm.api_key
                  or get_secret("XINFERENCE_API_KEY")
                  or "stub-xinference-key"
              )  # xinference does not need an api key, pass a stub key if user did not set one
              api_base = (
                  api_base
                  or litellm.api_base
                  or get_secret("XINFERENCE_API_BASE")
                  or "http://127.0.0.1:9997/v1"
              )
              response = openai_chat_completions.embedding(
                  model=model,
                  input=input,
                  api_base=api_base,
                  api_key=api_key,
                  logging_obj=logging,
                  timeout=timeout,
                  model_response=EmbeddingResponse(),
                  optional_params=optional_params,
                  client=client,
                  aembedding=aembedding,
              )
          else:
              args = locals()
              raise ValueError(
                  f"No valid embedding model args passed in - {args}"
              )
          if response is not None and hasattr(
              response, "_hidden_params"
          ):
              response._hidden_params[
                  "custom_llm_provider"
              ] = custom_llm_provider
          return response
      except Exception as e:
          ## LOGGING
          logging.post_call(
              input=input,
              api_key=api_key,
              original_response=str(e),
          )
          ## Map to OpenAI Exception
          raise exception_type(
              model=model,
              original_exception=e,
              custom_llm_provider="azure" if azure == True else None,
          )
  
imports: import os, openai, sys, json, inspect, uuid, datetime, threading
  from typing import Any, Literal, Union
  from functools import partial
  import dotenv, traceback, random, asyncio, time, contextvars
  from copy import deepcopy
  import httpx
  import litellm
  from litellm import client, exception_type, get_optional_params, get_litellm_params, Logging
  from litellm.utils import get_secret, CustomStreamWrapper, read_config_args, completion_with_fallbacks, get_llm_provider, get_api_key, mock_completion_streaming_obj, convert_to_model_response_object, token_counter, Usage, get_optional_params_embeddings, get_optional_params_image_gen
  from .llms import anthropic, together_ai, ai21, sagemaker, bedrock, huggingface_restapi, replicate, aleph_alpha, nlp_cloud, baseten, vllm, ollama, ollama_chat, cloudflare, cohere, petals, oobabooga, openrouter, palm, gemini, vertex_ai, maritalk
  from .llms.openai import OpenAIChatCompletion, OpenAITextCompletion
  from .llms.azure import AzureChatCompletion
  from .llms.huggingface_restapi import Huggingface
  from .llms.prompt_templates.factory import prompt_factory, custom_prompt, function_call_prompt
  import tiktoken
  from concurrent.futures import ThreadPoolExecutor
  from typing import Callable, List, Optional, Dict, Union, Mapping
  from .caching import enable_cache, disable_cache, update_cache
  from litellm.utils import get_secret, CustomStreamWrapper, TextCompletionStreamWrapper, ModelResponse, TextCompletionResponse, TextChoices, EmbeddingResponse, read_config_args, Choices, Message
label_desc: Use image node_id 7 for calling a global function with example usage: embedding(model, input, timeout, api_base, api_version, api_key, api_type, caching, user, custom_llm_provider, litellm_call_id, litellm_logging_obj, logger_fn) and returns: response